The getView() method of the class extending the BaseAdapter holds the state of the currently displayed view which is invalidated when scrolling the listview. So, in order to avoid this problem, proceed in the following manner.
• Create a nested class within the class (class which is extending BaseAdapter Class), namely, Viewholder.
• Declare all the views of an individual list item in this Viewholder Class.
• Create an object of this Viewholder class in the getView() method and initialize all the views declared in the Viewholder class using this object.
Example :
Activity activity;
publicclassViewHolder{
TextViewtextview;
CheckBoxcheckbox;
}
public View getView(finalint position, View convertView, ViewGroup parent)
{
View vi=convertView;
LayoutInflaterinflater = activity.getLayoutInflater();
vi = inflater.inflate (R.layout.listitem, null);
ViewHolder item=newViewHolder();
item.textview = (TextView)vi.findViewById(R.id.textview1);
item.checkbox = (CheckBox)vi.findViewById(R.id.checkbox1);
vi.setTag(item);
return vi;
}
Implement this and check the state of the checkbox while scrolling the listview.
Find us on Google+
Related Posts...
Mobile AppsTechnologies
Jan 8th, 2026
The automobile industry is undergoing a massive digital transformation. From connected cars and electric vehicles to ride-sharing and fleet management, mobile applications have become a core part of modern mobility. […]
Read more
Jan 6th, 2026
The construction industry is evolving faster than ever. With tighter deadlines, rising material costs, labour shortages, and increasing compliance requirements, managing construction projects using spreadsheets or manual methods is no […]
Read more
Dec 16th, 2025
For more than a decade, mobile apps have been at the centre of digital transformation. From ordering food and booking taxis to managing finances and running enterprises, apps have shaped […]
Read more