传递的ArrayList元素到下一个意图 [英] Pass ArrayList element to the next Intent
本文介绍了传递的ArrayList元素到下一个意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一个ArrayList元素传递给下一个意向,如果有一个人能帮助我!
{尝试
JSONArray jArray =新JSONArray(结果);
JSONObject的json_data = NULL;
的for(int i = 0; I< jArray.length();我++)
{
json_data = jArray.getJSONObject(ⅰ);
r.add(json_data.getString(Nom_Serveur));
}
setListAdapter(新ArrayAdapter<串GT;(这一点,android.R.layout.simple_expandable_list_item_1,R));
ListView控件列表= getListView();
list.setTextFilterEnabled(真);
list.setOnItemClickListener(新OnItemClickListener(){ 公共无效onItemClick(适配器视图<>为arg0,ARG1查看,
INT ARG2,长ARG3){
意图I =新意图(Serveur_EnPanne.this,Info_serveur.class);
i.putExtra(钥匙,??)
startActivity(ⅰ); }
解决方案
做的是这样的:
公共无效onItemClick(适配器视图<>为arg0,ARG1观,诠释ARG2,长ARG3){
意图I =新意图(Serveur_EnPanne.this,Info_serveur.class);
i.putExtra(钥匙,arg0.getSeletectedItem()的toString());
startActivity(ⅰ);
}
或
公共无效onItemClick(适配器视图<>为arg0,ARG1观,诠释ARG2,长ARG3){
意图I =新意图(Serveur_EnPanne.this,Info_serveur.class);
i.putExtra(钥匙,r.get(ARG2));
startActivity(ⅰ);
}
I'd like to pass an ArrayList element to the next Intent, if some one can help me!
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);
}
解决方案
do this way:
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);
}
or
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);
}
这篇关于传递的ArrayList元素到下一个意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文