Android的列表视图复制上滚动的项目 [英] Android listview duplicates the item on scroll

查看:123
本文介绍了Android的列表视图复制上滚动的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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()当数据被更改

这篇关于Android的列表视图复制上滚动的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆