开发者

Finding a ListView in Android

开发者_StackOverflow社区

How do I findViewById for the following XML?

<ListView android:id="@android:id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

I need it to set a list adapter.


Your XML must look like this:

<ListView android:id="@+id/ListView_Name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

in your code:

ListView listview = (ListView) findViewById(R.id.ListView_Name);


findViewById(android.R.id.list)

The ids prefixed with android: are all accessible under android.R.id. Similarly @android:drawableare accessible as android.R.drawable, etc...


This basic example shows you how to use an ArrayAdapter with a ListView. You should really need to ever actually mess with the ListView itself, just the elements that are put in it.

http://developer.android.com/resources/tutorials/views/hello-listview.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜