Skip to content Skip to sidebar Skip to footer

Listview Getting Refreshed After Scrolling The List In Android

thanks in advance , please forgive me if I am mistaking somewhere when explaining the question I have a Listview and a custom ArrayAdapter and the layout for the custom ArrayAdapte

Solution 1:

The Adapter is getting refresh, it the normal way to do it.

in your getView inflate the view only when its null, and create an Class Holder, so you can reuse your Widget views (TextViews and such) whenever you want :

@Overridepublic View getView(int postion, View convertView, ViewGroup parent) {
LayoutInflaterinflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Viewv= convertView;
ViewHolder h;
if(v == null){
    v=inflater.inflate(R.layout.adapter_layout, parent,false);
    h = newViewHolder();
    h.tv = (TextView)v.findViewById(ID);
    v.setTag(h);
}else{
   h = (ViewHolder) v.getTag();
}
Strings= getItem(position);
h.tv.setText(s);
return v;
}

privatestaticclassViewHolder{
TextView tv;
}

Solution 2:

Android ListView has designed such that it will be update,when you scroll list items.Actually when we bind Adapter with ListView,Automatically newview is called and bind all data.You might have noticed that on listview scroll getView() is being called.Watch this official video for clear understanding.

Post a Comment for "Listview Getting Refreshed After Scrolling The List In Android"