程序里 listView 中的信息,当我点击一行,它就会给出所选项的所有细节。在所选项中有image, imagename, price等。当我点击listview中的图像时,它必须填充所有的信息包括下一个activity 的图像。
在listView中显示信息
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/p.php");
try{
JSONArray earthquakes = json.getJSONArray("prop");
for(int i=0;i<earthquakes.length();i++){
JSONObject e = earthquakes.getJSONObject(i);
String BookName = e.getString("P_City");
PNames.add(BookName);
String BookImg = e.getString("Pname");
PImages.add(BookImg);
}
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
}
setListAdapter(new MobileArrayAdapter(this, PNames,PImages));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String selectedValue = (String) getListAdapter().getItem(position);
Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(), Searching.class);
// sending data to new activity
i.putExtra("product", selectedValue);
startActivity(i);
}
}
我可以把position传递到下一个类中。但是如何从一个已选项中获取所有的信息呢?