MainActivity
package com.example;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
public class MainActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.temp);
TabHost tabHost = getTabHost();
Intent intent = new Intent().setClass(this, temp02Activity.class);
tabHost.addTab(
tabHost.newTabSpec("temp01")
.setIndicator("Temp01")
.setContent(intent));
intent = new Intent().setClass(this, temp02Activity.class);
tabHost.addTab(tabHost.newTabSpec("temp02")
.setIndicator("Temp01")
.setContent(intent));
tabHost.setCurrentTab(0);
}
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
}
temp.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
'Programming > Android' 카테고리의 다른 글
Thread 와 Handler 테스트 (0) | 2013.04.13 |
---|---|
테이블 동적 생성 (0) | 2013.03.23 |
다중 액티비티 예제 (0) | 2013.03.23 |
안드로이드 레이아웃 예제 (0) | 2013.03.16 |
안드로이드 실습 (0) | 2013.03.09 |