dom*_*men 13 android android-listview android-cursoradapter
我正在使用不推荐使用的SimpleCursorAdapter来显示从Cursor到ListView的数据.我添加了附加参数0,它删除了代表性的警告,但我想使用更好的方式来显示数据.我已经阅读了一些内容Loader,但不知道如何实现它.什么是下面代码的更好的替代品?如何将此代码转换为使用Loader?
Cursor c = mDbHelper.getAllRecords();
startManagingCursor(c); //this is also deprecated
String[] from = new String[] { "Name" };
int[] to = new int[] { R.id.text1 };
SimpleCursorAdapter names =
new SimpleCursorAdapter(this, R.layout.names_row, c, from, to, 0);
setListAdapter(names);
Run Code Online (Sandbox Code Playgroud)
adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, cursor, from, to, 1);
这将执行自动重新查询.1设置为true,0设置为false.
| 归档时间: |
|
| 查看次数: |
14362 次 |
| 最近记录: |