我有一個ListView,它具有解析JSON中的數據。所以這是我的示例代碼:Android ListView onItemClick
ArrayList<HashMap<String, String>> myList = new ArrayList<HashMap<String, String>>();
/**
* parsing JSON...
* ...
* ...
* ...
*/
ListAdapter adapter = new SimpleAdapter(this, myList, R.layout.s_layout, new String[]{NAME, TEXT}, new int[]{R.id.name, R.id.text});
setListAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
String inName = ((TextView) view.findViewById(R.id.name)).getText().toString();
String inText = ((TextView) view.findViewById(R.id.text)).getText().toString();
Intent intent = new Intent(getApplicationContext(), StaffProfileActivity.class);
intent.putExtra("staff_name", inName);
intent.putExtra("staff_desc", inText);
startActivity(intent);
}
});
我的問題是,我怎樣才能把我的數據,意圖不使用
String inName = ((TextView) view.findViewById(R.id.name)).getText().toString();
我的意思是,如何從我的ListView得到我的數據,並給它意圖?
這個還可以嗎? Object ob = lv.getItemAtPosition(position); – elL 2013-02-28 08:30:18
@elL,是的,這也是正確的 – 2013-02-28 09:48:56
是的。這就是我接受它的原因。 – elL 2013-02-28 10:36:34