如何刷新里面SherlockFragment一个ListView? [英] How refresh a listView inside SherlockFragment?

查看:152
本文介绍了如何刷新里面SherlockFragment一个ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SherlockFragment内的ListView,但是当我做出适配器的任何变化,我不能更新屏幕列表视图。我想:adapter.notifyDataSetChanged(),但没有成功。谢谢的。

I have a listView inside a SherlockFragment, but I can not update the listView on screen when I make any changes to the Adapter. I tried: adapter.notifyDataSetChanged(), but without success. Thank's.

推荐答案

您应该更新传递给适配器notifyDatasetChanged()之前调用底层数据集;

You should be updating the underlying dataset that is passed to the adapter before calling notifyDatasetChanged();

例如:

有关ArrayAdapter在ListActivity
(ArrayList的是你用来备份您的ArrayAdapter ArrayList中)

For ArrayAdapter in a ListActivity ("arraylist" is the ArrayList you've used to back your ArrayAdapter)

arraylist.add(data);
arrayadapter = this.getListAdapter();
arrayadapter.notifyDatasetChanged();

这篇关于如何刷新里面SherlockFragment一个ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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