Android: TabHost without TabActivity
Before calling tabHost.setup(mLocalActivityManager); you need to add this line.
mlam.dispatchCreate(savedInstanceState);
tabHost.setup(mlam );
similarly, you need to add for onResume,
mlam.dispatchResume();
onPause(),
mlam.dispatchPause(isFinishing());
Please consider using Views
as the contents of your tabs. Not only will this result in less code, less consumed heap space, less consumed stack space, and lower CPU utilization, it will also get you past this problem. Here are two examples showing this technique.
public class ScoreboardActivity extends Activity {
LocalActivityManager mlam;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scoreboard);
mlam = new LocalActivityManager(this, false);
mlam.dispatchCreate(savedInstanceState);
TabHost th = (TabHost) findViewById(android.R.id.tabhost);
th.setup(mlam);
th.addTab(th.newTabSpec("Numpad").setIndicator("Numpad").setContent(R.id.tab1));
th.addTab(th.newTabSpec("CardCount").setIndicator("CardCount").setContent(R.id.tab2));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_scoreboard, menu);
return true;
}
@Override
protected void onResume(){
super.onResume();
mlam.dispatchResume();
}
@Override
protected void onPause(){
super.onPause();
mlam.dispatchPause(isFinishing());
}
}