在ListActivity是可以使用 this.getListView()addFooterView(footerView);
In ListActivity is can use this.getListView().addFooterView(footerView);
但如果我用的活动就不能使用 this.getListView()
but if I use Activity it can't use this.getListView()
我该怎么办?
当你使用活动
将 your_layout.xml
作为你的活动
的内容查看
。因此,的ListView
在 your_layout.xml
应该湾
Whenever you use Activity
you set your_layout.xml
as your Activity
's ContentView
. So the ListView
should b in your_layout.xml
.
这ListView控件应该在XML文件中定义说,一个id属性:(机器人:ID =@ + ID /列表
)。
你得到你的的ListView
对象的某些事情是这样的:
That ListView should have an id attribute defined in xml file say: (android:id="@+id/list"
).
You get your ListView
object some thing like this way:
setContentView(R.layout.your_layout);
ListView list = (ListView)findViewById(R.id.list);
list.addFooterView(view);
而当你使用 ListActivity
你得到你的的ListView
通过调用方法
And when you use ListActivity
you get your ListView
by calling method
ListView list = getListView(); // OR you can do
ListView list = (ListView)findViewById(android.R.id.list); //consider the android prefix..
和请注意,虽然定义任何 layout.xml
为 ListActivity
,你将有一个在布局具有这样的ID的ListView
:机器人:ID =@机器人:ID /列表
and please note that while defining any layout.xml
for ListActivity
you would have a ListView
in your layout having id of something like this: android:id="@android:id/list"