首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

,为什么setListAdapter(adapter)报错?(有源码)

2013-03-06 
求助,为什么setListAdapter(adapter)报错??(有源码)Cursor c getContentResolver().query(SMS_OUTBOX, n

求助,为什么setListAdapter(adapter)报错??(有源码)
Cursor c = getContentResolver().query(SMS_OUTBOX, null, null, null, null);
        startManagingCursor(c);
        String[] columns = new String[] { "body" };
        int[] names = new int[] { R.id.textView1 };
        adapter = new SimpleCursorAdapter(this, R.layout.main, c, columns,names);
        setListAdapter(adapter);


------------------
pro android 2这本书的源码,运行报错说没有 setListAdapter这玩意,要我自己写函数实现。问题是明明有这个东西啊。


:public void setListAdapter (ListAdapter adapter)   
 Provide the cursor for the list view
作用是为列表视图提供光标(不知道这样翻译对不对).
ListAdapter是列表适配器接口,继承于Adapter.
Extended Adapter that is the bridge between a ListView and the data that backs the list. Frequently that data comes from a Cursor, but that is not required. The ListView can display any data provided that it is wrapped in a ListAdapter.
当继承Adapter的时候是连接列表视图和数据之间的桥梁.通常这些数据来自于一个光标,但它并不是必须的.列表视图可以展示任何包含在ListAdapter中的数据.
[解决办法]
setListAdapter这个函数在listactivity里才有
[解决办法]
public class XXXXXX extends ListActivity

热点排行