Expandable List View Adapter Getview() Repeats Position
My ExpandableListView's adapter repeats the position of View and Images when I scroll below is my code. I used it without View holder and with view holder in both cases I face this
Solution 1:
Don't pick view by tag
use this
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Viewview= convertView;
StringgroupName= (String) getGroup(groupPosition);
LayoutInflaterinf= (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inf.inflate(R.layout.group_item, null);
holder = newViewHolder();
holder.arrowImage = (ImageView) view.findViewById(R.id.imageView1);
holder.groupName = (TextView) view.findViewById(R.id.laptop);
holder.groupName.setTypeface(null, Typeface.BOLD);
holder.groupName.setText(groupName);
setImageView(holder.arrowImage, groupPosition);
view.setTag(holder);
return view;
}
public ImageView getImageView(int position) {
return images[position];
}
publicvoidsetImageView(ImageView image, int position) {
images[position] = image;
}
staticclassViewHolder {
ImageView arrowImage;
TextView groupName;
}
this will prevent image repetition and consider every view as a new view
Post a Comment for "Expandable List View Adapter Getview() Repeats Position"