use*_*544 19 android listactivity android-activity
在ListActivity中可以使用 this.getListView().addFooterView(footerView);
但如果我使用Activity就无法使用 this.getListView()
我该怎么办?
Adi*_*mro 60
无论什么时候你使用Activity你设置your_layout.xml为你Activity的ContentView.所以ListView应该b your_layout.xml.
ListView应该在xml文件中定义一个id属性,说:( android:id="@+id/list").你可以通过ListView这种方式得到你的对象:
setContentView(R.layout.your_layout);
ListView list = (ListView)findViewById(R.id.list);
list.addFooterView(view);
Run Code Online (Sandbox Code Playgroud)
当你使用时,ListActivity你可以ListView通过调用方法获得
ListView list = getListView(); // OR you can do
ListView list = (ListView)findViewById(android.R.id.list); //consider the android prefix..
Run Code Online (Sandbox Code Playgroud)
并且请注意,虽然定义任何layout.xml的ListActivity你将有一个ListView在具有这样的事情ID您的布局:android:id="@android:id/list"
| 归档时间: |
|
| 查看次数: |
43840 次 |
| 最近记录: |