【发布时间】:2016-06-14 11:46:39
【问题描述】:
我一直在使用简单的适配器列表视图,但我的列表视图没有得到更新,尽管调用了 adapter.notifyDataSetChanged();那么它在简单的适配器中工作吗?下面是我的简单适配器代码。 我已经在全球范围内声明了简单的适配器
adapter = new SimpleAdapter(
getActivity(), ssLst,
R.layout.surgerysch_item, new String[]{
TAG_SIMRDNO, TAG_SIPNME, TAG_SISEX,
TAG_SIDOB, TAG_SIPROC, TAG_SIOTNME,
TAG_SIOTME, TAG_DRNAME}, new int[]{R.id.txtsimrdNo,
R.id.txtsiptnNme, R.id.txtsiSex,
R.id.txtsiDob, R.id.txtsiProc,
R.id.txtsiotNme, R.id.txtsiotTme, R.id.txtDrnme});
lstViw.setAdapter(adapter);
adapter.notifyDataSetChanged();
【问题讨论】:
-
在将其设置为列表视图之前调用
adapter.notifyDataSetChanged(); -
@Enlightened 你如何在
SimpleAdapter中获取arrayList?你是在创建新对象还是只是一个引用? -
调用adapter.notifyDataSetChanged()没有意义;设置适配器后立即。发布 SimpleAdapter 类。
-
发送适配器类和活动类
-
@mahadev,@janki 我已经通过使用 BaseAdapter 解决了它,并且我调用了 adapter.notifyDataSetChanged();在将适配器设置为列表视图之前