-
-
Save JavierSolis/a3efd0eb0c85f7cc1291b3bc8287f4b4 to your computer and use it in GitHub Desktop.
ejemplo de tab host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TabHost host = (TabHost)findViewById(R.id.tabHost); | |
| host.setup(); | |
| //Tab 1 | |
| TabHost.TabSpec spec = host.newTabSpec("Tab One"); | |
| spec.setContent(R.id.tab1); | |
| spec.setIndicator("Tab One"); | |
| host.addTab(spec); | |
| //Tab 2 | |
| spec = host.newTabSpec("Tab Two"); | |
| spec.setContent(R.id.tab2); | |
| spec.setIndicator("Tab Two"); | |
| host.addTab(spec); | |
| //Tab 3 | |
| spec = host.newTabSpec("Tab Three"); | |
| spec.setContent(R.id.tab3); | |
| spec.setIndicator("Tab Three"); | |
| host.addTab(spec); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context=".MainActivity"> | |
| <TabHost | |
| android:id="@+id/tabHost" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:layout_alignParentTop="true" | |
| android:layout_centerHorizontal="true"> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical"> | |
| <TabWidget | |
| android:id="@android:id/tabs" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content"></TabWidget> | |
| <FrameLayout | |
| android:id="@android:id/tabcontent" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent"> | |
| <LinearLayout | |
| android:id="@+id/tab1" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#ffc916" | |
| android:orientation="vertical"> | |
| <TextView | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:text="This is tab 1" /> | |
| </LinearLayout> | |
| <LinearLayout | |
| android:id="@+id/tab2" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#da8200" | |
| android:orientation="vertical"> | |
| <TextView | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:text="This is tab 2" /> | |
| </LinearLayout> | |
| <LinearLayout | |
| android:id="@+id/tab3" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#5b89ff" | |
| android:orientation="vertical"> | |
| <TextView | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:text="This is tab 3" /> | |
| </LinearLayout> | |
| </FrameLayout> | |
| </LinearLayout> | |
| </TabHost> | |
| </LinearLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment