मैंने हर जगह देखा और जवाबों में से किसी ने मुझे तब तक मदद की जब तक कि कोई नहीं किया।
था क्या मैं एक HolderView बनाने था और adpater के getView mathod में अपने सभी textviews और अन्य विगेट्स ऊपर लपेट:
static class ViewHolder
{
TextView text1;
TextView text2;
TextView text3;
}
और मैं भी एक ही decalared:
में इस वर्ग डाल लोगों को आम तौर पर वे अब अलग कर रहे हैं के रूप में:
TextView text1;
TextView text2;
TextView text3;
तो getView में लेआउट बढ़ा-चढ़ाकर के बाद सभी दृश्यों और विजेट की घोषणा:
holder = new ViewHolder();
holder.text1 = (TextView) vi.findViewById(R.id.textView2single);
holder.text2 = (TextView) vi.findViewById(R.id.textView3single);
holder.text3 = (TextView) vi.findViewById(R.id.textView4single);
onClick विधि के अंदर, मैं प्रयोग किया है:
View parentView = (View) v.getParent();
और फिर मेरी सभी विजेट घोषित फिर से इस parentview का उपयोग कर: माता-पिता पाने के लिए मेरी onClick मजबूर कर
text1 = (TextView) parentView.findViewById(R.id.textView2single);
text2 = (TextView) parentView.findViewById(R.id.textView3single);
text3 = (TextView) parentView.findViewById(R.id.textView4single);
इस im करने में सूची दृश्य आइटम की स्थिति, इसलिए उस माता-पिता के अंदर सभी विजेट आसानी से कॉल किए जा सकते हैं, फिर आप जो भी पसंद कर सकते हैं वह कर सकते हैं। यह एकमात्र तरीका है जिसे मैंने पाया है।
स्रोत
2013-08-21 23:42:04
'setOnItemClickListener()' सूचीदृश्य पर यदि u केवल पंक्ति आईडी – MAC
जरूरत है ([इस उदाहरण देखें] http://samir-mangroliya.blogspot.in/p/android-customized-listview.html) –