मेरे पास एक सूची दृश्य है जिसमें एक पार्स किए गए 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 से अपने डेटा मिलता है और करने के लिए इसे देने के लिए बिना आशय करने के लिए अपने डेटा से पारित सकता है आशय?
यह भी ठीक है इसका उपयोग कर रहा है? ऑब्जेक्ट ओबी = lv.getItemAtPosition (स्थिति); – elL
@ एएलएल, हाँ, यह भी सही है –
हां। यही कारण है कि मैंने इसे स्वीकार कर लिया। – elL