Android through the TabHost tab provides a container.
Information on the screen if you have a lot to express,
Use Tab to expand the screen effects can be expressed by using the information.
Some of the screen to display more than one tab, and
When you click the tab to the tab screen shows the structure belongs.
Tab to configure the following items should be used.
(1) TabHost classes: tap the button and tab detail across the entire tab container
(2) TabWidget Class: Tab button to manage the list.
Tab button to enter a text string, if necessary, set the icon
(3) FrameLayout container: Tab content management. For each tab of a widget inside a FrameLayout
※ Example Code
- TapView_Default.java
public class TapView_Default extends TabActivity {
private TabHost m_tabHost = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tapview_default_layout);
/** TabHost ID */
m_tabHost= (TabHost)findViewById(android.R.id.tabhost);
TabSpec aaa_TabSpec = m_tabHost.newTabSpec("aaa");
TabSpec bbb_TabSpec = m_tabHost.newTabSpec("bbb");
TabSpec ccc_TabSpec = m_tabHost.newTabSpec("ccc");
aaa_TabSpec.setIndicator("aaa", getResources().getDrawable(R.drawable.games));
aaa_TabSpec.setContent(new Intent(this,test_activity.class));
bbb_TabSpec.setIndicator("bbb", getResources().getDrawable(R.drawable.games));
bbb_TabSpec.setContent(new Intent(this,test_activity.class));
ccc_TabSpec.setIndicator("ccc", getResources().getDrawable(R.drawable.games));
ccc_TabSpec.setContent(new Intent(this,test_activity.class));
/** 탭을 TabHost 에 추가한다 */
m_tabHost.addTab(aaa_TabSpec);
m_tabHost.addTab(bbb_TabSpec);
m_tabHost.addTab(ccc_TabSpec);
/** TabHost 에 포함된 Tab의 색깔 변경가능 */
m_tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#534512"));
m_tabHost.getTabWidget().getChildAt(1).setBackgroundColor(Color.parseColor("#4E4E9C"));
m_tabHost.getTabWidget().getChildAt(2).setBackgroundColor(Color.parseColor("#6E8E1C"));
m_tabHost.getTabWidget().setCurrentTab(0);
}
}
- tapview_default_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">
<TabHost
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)
댓글 없음:
댓글 쓰기