2010/04/22
[Android Dev.] Tab 사용하기 - TabActivity
Tab 을 구성하기위해 TabActivity를 상속받아 Tab을 구성 하였다.
main.xml
java 소스
main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/TabView1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
<LinearLayout
android:id="@+id/TabView2"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
<TextView
android:id="@+id/TabView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TabView3"
/>
</FrameLayout>
</LinearLayout>
</TabHost>
java 소스
package com.neodreamer.MyTab;
<
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
public class MyTab extends TabActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
// 첫 번째 탭
spec = tabHost.newTabSpec( "Tab 01" );
spec.setIndicator( "Tab 01",
getResources().getDrawable( R.drawable.icon ) );
spec.setContent( R.id.TabView1 );
tabHost.addTab( spec );
// 두 번째 탭
spec = tabHost.newTabSpec( "Tab 02" );
spec.setIndicator( "Tab 02" );
spec.setContent( R.id.TabView2 );
tabHost.addTab( spec );
// 세 번째 탭
spec = tabHost.newTabSpec( "Tab 03" );
spec.setIndicator( "Tab 03" );
spec.setContent( R.id.TabView3 );
tabHost.addTab( spec );
tabHost.setCurrentTab( 0 );
}
}
Original Post : http://neodreamer-dev.tistory.com/419
Labels:
Android
,
Android Development
,
tab
,
TabActivity
,
TabHost
,
TabWidget
,
TistoryOldPost
,
안드로이드
,
안드로이드 개발
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment