简体   繁体   中英

android using setlistadapter() without extending listactivity

lots of searching and reading has not provided the answer to this problem. my activity does not extend ListActivity so this line throws an error. setListAdapter(fileList);

it is supposed to populate a listview, any solid help is much appreciated.

 ArrayAdapter<String> fileList =
    new ArrayAdapter<String>(this, R.layout.row, item);
    setListAdapter(fileList);

Obtain the reference of your ListView using findViewById(int) . Then call the method ListView.setAdapter(ListAdapter) on that reference with your adapter as the parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM