gpt4 book ai didi

android - 如何重置 ListView ?

转载 作者:行者123 更新时间:2023-11-29 22:06:56 24 4
gpt4 key购买 nike

我在这个 Activity 中有一个 ListView

首先,我将用这个显示 ListView

adapter = new CustomAdapter_LatestNews(this, title, category, date,
imagepath);

lv.addFooterView(constant.AdMob());
lv.setAdapter(adapter);

我正在使用扩展基本适配器的自定义适配器。

public View getView(int position, View convertView, ViewGroup parent)

在此 Activity 中,我有一个刷新按钮,用于更新数据并回调相同的 Activity 。

startActivity(new Intent(Main_AllLatestNews.this, Main_AllLatestNews.class));
finish();

getview 似乎在重用数据?

在按下刷新按钮之前

result > image 0 0 0 0 1 0 1 0 0 0 correct display (no matter how i scroll)

点击刷新按钮后

result > image 1 1 1 1 1 1 1 1 1 1 incorrect display (scroll will cause this)

如何解决这个问题?

最佳答案

你可以试试,它对我有用:

ListView 和适配器的初始化:

listView = (ListView) findViewById(R.id.list_view);
adapter = new MessageAdapter(this);
listView.setAdapter(adapter);

重置列表和适配器数组:

listView.removeAllViewsInLayout();
listMessages.clear();

关于android - 如何重置 ListView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10576874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com