我在學習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().
也許這將是更好的有標籤的定義獨立的活動,只是把它在所有其他活動。但是,我不知道如何做到這一點。
請提出解決此問題的建議。先謝謝你。
你想要做什麼更多的信息鏈接? –