android:TabHost Without TabActivity

TabActivity 该类已经过期

要使用tab可以直接继承Activity,不过要做相应的修改。

TabHost tabHost = getTabHost();改为

TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);

 

添加

 

LocalActivityManager lam = new LocalActivityManager(MainActivity.this, false);

lam.dispatchCreate(savedInstanceState);

mHost.setup(lam);

 

 

 

 

@Override
protected void onPause() {
    lam.dispatchPause(isFinishing());
    super.onPause();
}
@Override
protected void onResume() {
    lam.dispatchResume();
    super.onResume();
}

可参考:http://wazai.net/2109

http://stackoverflow.com/questions/3163884/android-tabhost-without-tabactivity

posted on 2012-05-18 13:31  老Zhan  阅读(695)  评论(0编辑  收藏  举报