如果有人可以帮助我,我想将ArrayList元素传递给下一个Intent!
try{
JSONArray jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++)
{
json_data = jArray.getJSONObject(i);
r.add(json_data.getString("Nom_Serveur"));
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, r));
ListView list = getListView();
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Intent i = new Intent(Serveur_EnPanne.this, Info_serveur.class);
i.putExtra("key", ??)
startActivity(i);
}
最佳答案
这样做:
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent i = new Intent(Serveur_EnPanne.this, Info_serveur.class);
i.putExtra("key", arg0.getSeletectedItem().toString());
startActivity(i);
}
要么
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent i = new Intent(Serveur_EnPanne.this, Info_serveur.class);
i.putExtra("key", r.get(arg2));
startActivity(i);
}