मैं एक गतिशील arrayadapter.it कार्यों से प्रदर्शित करने के लिए व्यूल्डर का उपयोग कर रहा हूं लेकिन जब मैं सूची स्क्रॉल करता हूं तो डेटा अनियमित रूप से प्रदर्शित होता है। मैं चाहता हूं कि मेरी सूची दृश्य केवल एक बार आबादी हो, हर बार जब मैं अपनी सूची स्क्रॉल करता हूं। कोई सुझाव? यहाँ मेरी कोडव्यू धारक को कैसे कार्यान्वित करें?
public View getView(int position, View convertView, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid unneccessary calls
// to findViewById() on each row.
ViewHolder holder;
// When convertView is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the convertView supplied
// by ListView is null.
if (convertView == null) {
convertView = mInflater.inflate(R.layout.sample, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
if(_first==true)
{
if(id<myElements.size())
{
holder.name.setText(myElements.get(id));
holder.icon.setImageBitmap(mIcon1);
id++;
}
else
{
_first=false;
}
}
//holder.icon.setImageBitmap(mIcon2);
/*try{
if(id<myElements.size())
id++;
else
{
id--;
}
}
catch(Exception e)
{
android.util.Log.i("callRestService",e.getMessage());
}*/
return convertView;
}
static class ViewHolder {
TextView name;
ImageView icon;
}
है जब सूची यह इस तरह दिखता है भरी हुई है: कुछ डेटा http://i.stack.imgur.com/sMbAD.png यह इस तरह दिखता है स्क्रॉल के बाद http://i.stack.imgur.com/NrGhR.png, और फिर अगर मैं शुरुआत करने के लिए स्क्रॉल यह http://i.stack.imgur.com/0KjMa.png
लग रहा हैपीएस: मेरी सूची को वर्णानुक्रम में होना चाहिए
क्या आप अपने आउटपुट के स्क्रीन शॉट पोस्ट कर सकते हैं? –
@ टिलसन द फाइटर: स्नैपशॉट्स पोस्ट कर चुके हैं। – Ads