Android的列表视图复制上滚动的项目视图、项目、列表、Android

2023-09-05 02:50:59 作者:孤人寡言

我有一个TextView的列表视图,每行中的按钮。按钮背景使用一些条件设定。如果我在列表中滚动的行数,按钮背景获得洗牌。这意味着在滚动错背景设置为按钮的背景。我该如何解决这个问题?我的适配器类,如下所示:

I have a listview with one textview and a button in each row. Button background is setting using some conditions. If i have number of rows in list and scrolled, the button background get shuffling. That means on scrolling wrong background is setting as button background. How can i resolve this issue? My adapter class is as shown below:

    public View getView(int position, View convertView, ViewGroup parent) {
    final PhotoCondtionthreeItemView item;
    Photo place = (Photo) getItem(position);

    if (convertView != null) {
        item = (PhotoCondtionthreeItemView) convertView;
    } else {
        item = new PhotoCondtionthreeItemView(context, place,
                membershipSign);
    }

    item.setShareTag(place.getLink()+"@@@"+place.getServerPhotoId());

    item.setBaseLayoutTag(place.getLink() + "@@@"
            + place.getServerPhotoId() + "@@@" + place.getIsGallery()
            + "@@@" + place.getId());
    File file;
    try {
        file = new File(place.getLink());
        if (file.exists()) {
            if (cache.containsKey(place.getLink())) {
                item.setThumbImg(cache.get(place.getLink()));
            } else {
                Bitmap bitmap = BitmapResizer.decodeFile(file, 50, 50);
                item.setThumbImg(bitmap);
                cache.put(place.getLink(), bitmap);
            }
        } else {
            item.setThumbImgMissing();
        }

    } catch (Exception e) {
        Log.e("PhotoCondThree ERROR", e.toString());
    }

    return item;
}

在PhotoCondtionthreeItemView类创建的行列表。 (未使用XML为列表行)。

In PhotoCondtionthreeItemView class created the row for list. (not used xml for list row).

谁能帮助我?

感谢您

推荐答案

呼叫 yourListViewadapter.notifyDataSetChanged()当数据被更改