Skip to content Skip to sidebar Skip to footer

After Scrolling Listview, Listview Items Getting Repeatedly In Android

In my project,While clicking on grid view items, i need to add that in list view, So it to be a dynamic one.But After adding 8 to 9 items list view showing items repeatedly on scro

Solution 1:

try overloading the following two functions in your ProductCartCustomAdapter class:

getItemViewType()

getViewTypeCount()

after overloading they may look like :

@OverridepublicintgetItemViewType(int position) {
// TODO Auto-generated method stubreturn position;
}

@OverridepublicintgetViewTypeCount() {
// TODO Auto-generated method stubreturn getCount();
}

hope this would solve your problem.

Solution 2:

You are using ViewHolder but not in a proper way,

When you do convertView.setTag(mViewHolder); You have to tell view holder that which tag corresponds to which id by doing i.e convertView.setTag(R.id.yourtextviewID, viewHolder.textView); for each and every widget you have used after convertView.setTag(mViewHolder); line,

Now the important part is after you do

else {

        mViewHolder = (ViewHolder) convertView.getTag();
    }

you also have to set the tags to thier correct positions so the items may appear properly

viewHolder.textView.setTag(position);

for each and every widget you use Your ViewHolder is not a static class,in general viewholders are static class

staticclassViewHolder

everything else is correct, no need to do notifyDatasetChanged

Solution 3:

try calling youradapter.notifyDataSetChanged() after you are adding/deleting

Post a Comment for "After Scrolling Listview, Listview Items Getting Repeatedly In Android"