Issues with Android TabHost Example

前端 未结 4 1232
别那么骄傲
别那么骄傲 2020-11-30 07:07

I have been attempting to implement the \'advanced\' tabwidget example from google. But, when it tries to call tabHost.addTab(spec); I get a stack trace from t

4条回答
  •  自闭症患者
    2020-11-30 07:53

    I spent the last hour or so going through that tutorial. Here's the problems and fixes for it that I dealt with:

    Step 2: When creating your activities, if you do not create them through the manifest then you'll need to add them to the manifest manually.

    Add these lines to AndroidManifest.xml:

      
            
      
            
              
            
    

    Step 3: You are only instructed to create the ic_tab_artists.xml file. You'll need to create one for ic_tab_songs.xml and ic_tab_albums.xml as well. You can just duplicate the ic_tab_artists.xml (or change the HelloTabView.java tab specs to use the artists.xml file for each tab).

    Step 4: The third to last line under /res/layout/main has a typo (a ; instead of a :)

          android:padding="5dp" />
        
    
    

    Step 6: There is a typo that uses calls mTabHost instead of tabHost. Change it.

    As already cited the getIntent() function on the last line isn't appropriate. I just call the tab based on it's id. eg:

    tabHost.setCurrentTabByTag("albums");
    

提交回复
热议问题