Android 2.1 NullPointerException with TabWidgets

后端 未结 4 1624
猫巷女王i
猫巷女王i 2021-01-06 03:49

I have an issue I have not been able to figure out and it is only happening on devices running <2.1. It works fine on android 2.2. I have ansynchronous task that displa

4条回答
  •  一个人的身影
    2021-01-06 03:54

    An easy solution is to set the tabWidget visibility to gone in your layout

    
    

    Then once you have defined your tabs content, you can make it visible again:

    // Add tab content (here a fragment class)
    tabHost.addTab(
        tabHost.newTabSpec("tag1").setIndicator("Title"), 
        contentFragment.class, 
        null);
    
    // Set tabWidget visible again
    tabWidget.setVisibility(View.VISIBLE);
    

提交回复
热议问题