I want to update the title of the tab according to the content of my child activity.
However, when I call:
TabActivity parent = (TabActivity) getParent();
TabHost parentHost = (TabHost) parent.getTabHost().findViewById(android.R.id.tabhost);
in the child, the program crashes.
Anyone can help me discover the problem and solve it?
My TabActivity setup:
public class Tab extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tab);
final TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
View newTab = (View) LayoutInflater.from(this).inflate(R.layout.tabmini, null);
TextView text0 = (TextView) newTab.findViewById(R.id.tab_label);
text0.setText("new tab");
tabHost.setup(this.getLocalActivityManager());
tabHost.setCurrentTab(1);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(newTab).setContent(new Intent(this, BrowserActivity.class)));
}
public void addTab(TabHost tabHost, String startPage){
//...Add a new Tab
}
}
.
stackoverflow.comm
No comments:
Post a Comment