[英]ListActivity with Cursor
有谁知道使用CursorAdapter的简单示例? 这是我现在正在做的事情,并且由于RuntimeException而崩溃。 我肯定是我是新手,所以找不到简单的东西,因为找不到使用Cursor的ListView的任何简单示例。
谢谢,
...
公共最后一个类MyListActivity扩展了ListActivity {私有类MyCursorAdapter扩展了CursorAdapter {公共MyCursorAdapter(上下文上下文,光标游标){super(context,cursor); //崩溃...
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myDB_ = new MyDB(this);
myDB_.open();
Cursor cursor = myDB_.read();
startManagingCursor(cursor);
MyCursorAdapter adapter = new MyCursorAdapter(this, cursor);
...
Android开发人员资源中的记事本教程将CursorAdapter与ListView一起使用。 您可以在此处找到本教程的相关部分: http : //developer.android.com/resources/tutorials/notepad/notepad-ex1.html
您可以在setViewBinder
上使用SimpleCursorAdapter
将值映射到SimpleCursorAdapter本身不支持的视图。 您可以在此处看到使用setViewBinder
将数据从内容提供程序绑定到CheckBox的示例: ListView中CheckBox的选中状态
您可以使用setViewBinder
将图像绑定到imageButtons。 这样,您不必创建自己的ListAdapter。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.