SimpleCursorAdapter ---的学习
2010-04-09 12:06
197 查看
以前对newview 和bindview的理解不是很深,今天特意研究研究。
开始时有多少可以显示的view就执行下多少下newView,后面滚动listview的时候 只执行bindView,除非又可以看到新的item如上面的如果可以看到第8个item的时候,那就要newView.否则都不执行newView,下面是listview滚动的时候的执行log.
onQueryComplete()-->当AsyncQueryHandler async async.startQuery()后面的时候就会执行onQueryComplete().这个时候来更新listview.调用adapter.changeCursor(newCursor)-->cursor变化的时候来控制更新adpter.
总结:
一般情况SimapleCursorAdapter是用来和数据库有关cursor,AsyncQueryHandler 的运用。一般newView中只负责View的部分,setTag(View)-->只对view,对数据的处理都放在bindView中,不然会有异常情况出现!因为newView在listView滚动的情况下大部分时间不执行,除非上面所说的!总的来说android的用这个就实现了界面更新时候只是更新了数据。而view还是和以前一样。
newView 0 bindView 0 newView 1 bindView 1 newView 2 bindView 2 newView 3 bindView 3 newView 4 bindView 4 newView 5 bindView 5 newView 6 bindView 6 newView 7 bindView 7
开始时有多少可以显示的view就执行下多少下newView,后面滚动listview的时候 只执行bindView,除非又可以看到新的item如上面的如果可以看到第8个item的时候,那就要newView.否则都不执行newView,下面是listview滚动的时候的执行log.
bindView 8 bindView 9 bindView 10 bindView 11 bindView 12 bindView 13 bindView 14 bindView 15
class QueryHandler extends AsyncQueryHandler { QueryHandler(ContentResolver res) { super(res); } @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { // Log.i("@@@", "query complete: " + cursor.getCount() + " " + // mActivity); if (cursor != null) { System.out.println("onQueryComplete......."); } mActivity.initCursor(cursor);//更新adpter } }
onQueryComplete()-->当AsyncQueryHandler async async.startQuery()后面的时候就会执行onQueryComplete().这个时候来更新listview.调用adapter.changeCursor(newCursor)-->cursor变化的时候来控制更新adpter.
总结:
一般情况SimapleCursorAdapter是用来和数据库有关cursor,AsyncQueryHandler 的运用。一般newView中只负责View的部分,setTag(View)-->只对view,对数据的处理都放在bindView中,不然会有异常情况出现!因为newView在listView滚动的情况下大部分时间不执行,除非上面所说的!总的来说android的用这个就实现了界面更新时候只是更新了数据。而view还是和以前一样。
相关文章推荐
- Android列表视图(ListView--SimpleCursorAdapter)学习
- Android列表视图(ListView--SimpleCursorAdapter)学习
- Android学习之适配器SimpleCursorAdapter
- Android学习之Adapter:SimpleAdapter,SimpleCursorAdapter,ArrayAdapter(数据库 列表)
- Android基础学习之BaseAdaptery以及SimpleCursorAdapter的使用
- Android开发模板------自定义SimpleCursorAdapter的使用
- 为SimpleCursorAdapter增加CheckBox支持
- 继承SimpleCursorAdapter定制Adapter
- ListView之SimpleCursorAdapter列表--3
- 2011-06-14 11:28 SimpleCursorAdapter中的newView(),bindVew(),changeCursor()&&显示SD卡中的音乐文件
- Adapter基础讲解-SimpleCursorAdapter使用示例
- 为SimpleCursorAdapter增加CheckBox支持 推荐
- SQLiteDatebase 、SQLiteOpenHelper、SimpleCursorAdapter
- android的adapter:ArrayAdapter,SimpleAdapter,SimpleCursorAdapter
- 和SimpleCursorAdapter有关的小问题
- SimpleCursorAdapter和_id
- View(视图)——ListView之BaseAdapter和SimpleCursorAdapter以及网格视图代码视图
- Android适配器之-----SimpleCursorTreeAdapter
- SimpleCursorAdapter和ListView的结合使用
- Android API : SimpleCursorAdapter()