2011.07.05——— android notifyDataSetChanged不管用
参考:
http://blog.csdn.net/xiakq/article/details/6576763
http://www.xiaoyao.net/?p=81
代码很简单 如下:
SimpleCursorAdapter sca = new SimpleCursorAdapter(ClassBaseActivity.this, R.layout.content_item, cursor, new String[]{"name"}, new int[]{R.id.content_text});
我建立了一个SimpleCursorAdapter 我的crusor发生的变化 增加或者删除了一条数据 这时 我就需要更新SimpleCursorAdapter ,然后 我就这样写了:
sca.notifyDataSetChanged();
但是 不行 ui没有变化
后来 上网找 说是数据源必须改变了
cursor = cs.getAll();
sca.notifyDataSetChanged();
然后 我就重新获得了crusor 但是依然不行
最后 终于在网上找到 必须告诉SimpleCursorAdapter 我们改变了数据源 也就是:
cursor = cs.getAll();
sca.changeCursor(cursor);
sca.notifyDataSetChanged();
这样 就ok 了
分享到:
相关推荐
blog: http://blog.csdn.net/u013293125/article/details/52858396 http://www.cnblogs.com/ityizhainan/p/5976845.html
博客:http://blog.csdn.net/qibin0506/article/details/46404745的代码
mAdapter.notifyDataSetChanged(); mListview.setSelection(mDatas.size() - 1); } @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Log.e("MediaManager", ...
import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view....
Adapter.notifyDataSetChanged(); } }; private OnItemClickListener lvLis = new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ...
关于ListView中adapter调用notifyDataSetChanged失效的原因总结 详细见博客: http://blog.csdn.net/whitley_gong/article/details/50562634
list_adapter.notifyDataSetChanged(); break; default: break; } scan_timer_select = (scan_timer_select + 1) % 4; } }; private BluetoothAdapter.LeScanCallback mLeScanCallback ...
主要介绍了Android 调用notifyDataSetChanged方法失败解决办法的相关资料,需要的朋友可以参考下
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import android.widget...
m_simpleadapter.notifyDataSetChanged(); } } }; MyGallery.OnItemClickListener itemclick_listener2 = new MyGallery.OnItemClickListener() { @Override public void onItemClick(MyAdapterView<?> ...
主要介绍了浅谈Android中适配器的notifyDataSetChanged()为何有时不刷新,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
ViewPager中使用FragmentPagerAdapter.notifyDataSetChanged无法更新当前Fragment解决方案
FragmentPagerAdapter调用notifyDataSetChanged无效及解决方案
Android中ListView用NotifyDataSetChanged实现添加数据时动态刷新
仿zaker效果的拖拽排序。可以动态设置列数,动态增加或者减少item,当一页填满自动增加到下一页,当页数大于1,可以左右翻页。项目地址:... mAdapter.notifyDataSetChanged(); } });
使用方式和RecyclerView完全一致,不需要额外的layout,不需要写特殊的adater。 加载效果内置了AVLoadingIndicatorView上的所有效果,可以根据需要指定。项目地址:https://github.com/jianghejie/XRecyclerView ...
ViewPager使用中notifyDataSetChanged无法更新问题解决
demoAdapter.notifyDataSetChanged(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater()....