Michael J wrote:
> I'm pretty confused trying to create a tabbed application and could
> really use some assistance...
> 
> I'm trying to create a layout (main.xml) with 4 tabs, each tab
> containing a separate linear layout, which I would like to be able to
> define in a separate layout xml file.  I've been able to create the 4
> tabs, but can't get any content to come up for any of them, just a
> blank screen.
> 
> I pretty much copied the "Hello, TabWidget" example code from Google's
> Android Developers site to get the existing tabs.  By the way, I also
> can't seem to use the Layout editor to edit main.xml, I can only edit
> the xml itself.  I can, however, use the layout view for my other
> layouts (tab1.xml, tab2.xml, tab3.xml, and tab4.xml).
> 
> THANKS FOR ANY ASSISTANCE YOU CAN OFFER!
> 
> This is my java code:
> 
> public class myProject extends TabActivity {
>     private TabHost tabHost;
> 
>       /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
> 
>         tabHost = getTabHost();
> 
>         tabHost.addTab(tabHost.newTabSpec("tab_test1").setIndicator
> ("Tab 1").setContent(R.layout.tab1));
>         tabHost.addTab(tabHost.newTabSpec("tab_test2").setIndicator
> ("Tab 2").setContent(R.layout.tab2));
>         tabHost.addTab(tabHost.newTabSpec("tab_test3").setIndicator
> ("Tab 3").setContent(R.layout.tab3));
>         tabHost.addTab(tabHost.newTabSpec("tab_test4").setIndicator
> ("Tab 4").setContent(R.layout.tab4));
> 
>         tabHost.setCurrentTab(0);
>     }

setContent() takes an ID of a widget in the tab host's own layout, not
another layout.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to