Jam*_* Gu 13 android onresume android-activity
我正在使用列表适配器来显示不同的商店,当有人选择商店时,它会将他们带到一个新活动,在那里他们可以将商店添加到该屏幕上的收藏夹.
该调用上有一个Back按钮finish();
,可以通过listview返回到屏幕.
现在的问题是listview没有更新(即没有显示商店已经添加到收藏夹).我尝试了这段代码,但没有运气:
@Override
public void onResume() {
super.onResume();
list.setAdapter(null);
updateMyList();
adapter=new LazyAdapter(this, ((String[])names.toArray(new String[0])),
((String[])status.toArray(new String[0])));
list.setAdapter(adapter);
}
Run Code Online (Sandbox Code Playgroud)
updateMyList()
调用服务器API并更新名称和状态数组.
使用此代码,列表并未真正更新...
Lal*_*ani 31
你应该在你的onCreate()
内部设置适配器,你只onResume()
需要调用adapter.notifyDataSetChanged()
新的数据集.这将使用新的数据集刷新ListView.
归档时间: |
|
查看次数: |
26366 次 |
最近记录: |