• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Tab Layout tutorial doesn't work

I have followed the setup instructions from this web page

Tab Layout | Android Developers

there were some minor typos which i have ammended but i can't run the code because i have one error that i can't solve.

the last line in the onCreate function that lives in the main java file

tabHost.setCurrentTab(getIntent());

has an error.

The method setCurrentTab(int) in the type TabHost is not applicable for the arguments (Intent) HelloTabWidge.java

the suggestion is to change it to

tabHost.setCurrentTabByTag(getIntent());

but this receives exactly the same error.

So i can't run my app until this is resolved. can anyone help me out with this.

Ilan
 
Using tabHost.setCurrentTab(0) will select the first tab.

Alternately, you can use tabHost.setCurrentTabByTag() with the string that you used in the newTabSpec() method to select a tab. For example, if you were following that tutorial, you could use tabHost.setCurrentTabByTag("artists")
 
Back
Top Bottom