使用的android setlistadapter()不延长listactivity [英] android using setlistadapter() without extending listactivity

查看:83
本文介绍了使用的android setlistadapter()不延长listactivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多搜索和阅读还没有提供这个问题的答案的问题。 我的行为不扩展ListActivity所以这行抛出一个错误。 setListAdapter(fileList)中的;

它应该填充列表视图,任何固体的帮助是非常AP preciated。

  ArrayAdapter<字符串>的fileList =
    新的ArrayAdapter<字符串>(这一点,R.layout.row,项目);
    setListAdapter(fileList)中的;
 

解决方案

获取你的的ListView的参考使用 findViewById(INT)。然后调用 ListView.setAdapter(ListAdapter)上的参考方法与你的适配器作为参数。<​​/ P>

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.

这篇关于使用的android setlistadapter()不延长listactivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆