Android Exception: Did you forget to call 'public void setup (LocalActivityManager activityGroup)'

前端 未结 2 1950
误落风尘
误落风尘 2020-11-27 05:00

MyCode:

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInsta         


        
相关标签:
2条回答
  • 2020-11-27 05:35

    you need change MainActivity's base class from Activity to ActivityGroup, as follows:

      public class MainActivity extends ActivityGroup {
      ...
      }
    

    ActivityGroup will take care of an instance of LocalActivityManager. So you don't need to create it. After the base class is changed, just call getLocalActivityManager() function defined in the base class to get that instance. Call tabHost's setup function like this:

      tabHost.setup(this.getLocalActivityManager());
    
    0 讨论(0)
  • 2020-11-27 05:45

    Instead of setup():

    LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false);
    setup(mLocalActivityManager);
    
    0 讨论(0)
提交回复
热议问题