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中的数据.

解决方案 »

  1.   

    setListAdapter这个函数在listactivity里才有
      

  2.   

    public class XXXXXX extends ListActivity
      

  3.   

    看到回复也不知道怎么改的啊,难道要重新建立一个.java文件来继承listactivity?
      

  4.   

    将继承的Activity改为继承ListActivity即可
      

  5.   

    将继承的Activity改为继承ListActivity即可
    正解
      

  6.   

    public class ListViewTestActivity extends ListActivity
      

  7.   

    extends ListActivity或者extends ListFragment,才能用setListAdapter