gpt4 book ai didi

android - 如何刷新 ListView 控件;

转载 作者:行者123 更新时间:2023-11-29 17:54:51 24 4
gpt4 key购买 nike

我在mMessageReceiver中修改了ListView控件的源数据,但是ListView控件还是显示旧行,如何刷新 mMessageReceiver 中的 ListView 控件?谢谢!

   private ListView lv; 

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
HandleRule.SaveFullRule(PublicPar.SharedRule);
//I hope to refresh ListView control
}
};


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sms_main);

LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter(PublicPar.LocalBroadcastForRule));

PublicPar.myContext=getApplicationContext();
lv = getListView();

FillListView();
}

private void FillListView(){
Cursor c=HandleRule.GetCursorOfAllRuleMain();
String[] cols=new String[] {"name"};
int[] views=new int[]{R.id.mylisttext};
SimpleCursorAdapter myAdapter=new SimpleCursorAdapter(this,R.layout.sms_simple_list_item_multiple_choice,c,cols,views);
lv.setAdapter(myAdapter);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
SetCheckBoxStatus();
}

最佳答案

myAdapter..notifyDataSetChanged();

应该刷新你的 ListView 。
有关详细信息,请参阅 developer page .

关于android - 如何刷新 ListView 控件;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20183925/

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