如何可以刷新的ListView当机器人标签 [英] How can refresh ListView when tab in android
本文介绍了如何可以刷新的ListView当机器人标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序有三个选项卡与的ListView
显示每个人在里面。如何写code刷新的ListView
时,标签之间点击?
@覆盖
公共无效onTabChanged(字符串tabId){
如果(tabId ==tab_1中)
{
刷新的ListView ???
}
}
解决方案
您不刷新的ListView
。您确保底层适配器
的最新数据,并且将与的ListView
来显示它。因此,举例来说,如果你使用的是 SimpleCursorAdapter
,呼叫重新查询()
在光标
。
My application have three tabs with ListView
display inside each one. How to write code to refresh ListView
when click between tabs ?
@Override
public void onTabChanged(String tabId) {
if(tabId == "tab_1")
{
refresh ListView ???
}
}
解决方案
You don't refresh the ListView
. You ensure the underlying Adapter
has the latest data, and it will work with the ListView
to display it. So, for example, if you are using a SimpleCursorAdapter
, call requery()
on the Cursor
.
这篇关于如何可以刷新的ListView当机器人标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文