1
當我向下滾動時,My ExpandableListView的適配器重複查看和圖像的位置是我的代碼。在這兩種情況下,我都沒有使用View holder和View holder,所以我面臨這個問題。Expandable列表視圖適配器getView()重複位置
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
View view = convertView;
String groupName = (String) getGroup(groupPosition);
if (view == null) {
LayoutInflater inf = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inf.inflate(R.layout.group_item, null);
holder = new ViewHolder();
holder.arrowImage = (ImageView) view.findViewById(R.id.imageView1);
setImageView(holder.arrowImage, groupPosition);
view.setTag(holder);
holder.groupName = (TextView) view.findViewById(R.id.laptop);
holder.groupName.setTypeface(null, Typeface.BOLD);
holder.groupName.setText(groupName);
} else {
holder = (ViewHolder) view.getTag();
holder.groupName = (TextView) view.findViewById(R.id.laptop);
holder.groupName.setTypeface(null, Typeface.BOLD);
holder.groupName.setText(groupName);
}
return view;
}
public ImageView getImageView(int position) {
return images[position];
}
public void setImageView(ImageView image, int position) {
images[position] = image;
}
static class ViewHolder {
ImageView arrowImage;
TextView groupName;
}
感謝sourabh devpura但它不工作根據我的要求.. –
當我更改groupClicklistner中的組顏色,重複的位置也改變它的顏色.. –
@UmairIrshad請把你的新代碼在q uotation –