Android - Tabhost working in Activity class

前端 未结 7 939
温柔的废话
温柔的废话 2020-12-09 12:28

OK, I must be overlooking something silly because I am unable to get my tabhost to display in my Activity class. I am getting the dreaded force close when I try to run the

7条回答
  •  死守一世寂寞
    2020-12-09 12:29

    If you have a scenario in which you need to use Activity class for your Tabhost you can try the following it works.

        tabHost = (TabHost) findViewById(R.id.tabhost); //here tabHost will be your Tabhost
        LocalActivityManager mLocalActivityManager = new LocalActivityManager(mActivity, false);
        mLocalActivityManager.dispatchCreate(state); // state will be bundle your activity state which you get in onCreate
        tabHost.setup(mLocalActivityManager);
    

提交回复
热议问题