我在学习android的过程中。 想要实现标签式浏览功能;为了这个目的,我有以下活动如何从另一个活动调用TabActivity getTabHost()?避免NullPointerException
public class CustomList extends ListActivity {
....
and inside this (and other activities I want to put the tabs)
for example:
Resources res = getResources();
**TabActivity ta = new TabActivity();**
TabHost host = **ta.getTabHost();** // this line returns **NullPointerException**
host.addTab(host.newTabSpec("first")
.setIndicator("First")
.setContent(new Intent(this, First.class)));
These lines are included inside OnCreate().
也许这将是更好的有标签的定义独立的活动,只是把它在所有其他活动。但是,我不知道如何做到这一点。
请提出解决此问题的建议。先谢谢你。
你想要做什么更多的信息链接? –