T7

/ 34 GridViewActivity $

"J], frft/H main.xml iRifMn "TabView", ftflMWftj" T0PF:

<Button Android:id "@+id/tab_demo button" Android:layout_width="wrap content" Android:layout height="wrap_content" Android:text="TabView"/>

fcX 't id>; "tab demobutton" (W&ffl, "Tab View \

ssiiqii «r'-m^y'&ijftM //a-iw&ji KW^s private Button.OnClickListener tab demo button listener = new Button.OnClickListener() {

public void onCl ick. (View v) { Intent intent new Intent();

intent.setClass(MainActivity.this, TabDemoActivity.class); startActivity(intent); I

fyitiJmJnZh Tab Demo Activity <, -fi" fk'Jc TabDemoActi vity ftfj Sft» ^»ifericN TabActivity, ft&iJftiWiin public class TabDemoAct.vity extends TabActivity (

/** Called when the activity is first created. *■/ @0verri de public void onCreate(Bundle savedlnstanceState) I super.onCreate(savedlnstanceState); setTit.le ("TabDemoActivity") ; TabHost tabHost getTabHost ();

LayoutInflater.from(this).inflate(R.layout.tab_demo, tabHost.getTabContentView(), true);

tabHost.addTab(tabHost.newTabSpec("tabl") .set Indicator("tabl") .setContent(R.id.viewl));

tabHost.addTab(tabHost.newTabSpec("tab3") .set Indicator("tab2") .setContent(R.id.view2));

tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3") .setContent(R.id.view3)); I 1

getTabHost TabHost, ^S^ftj fMimZtiiSCft tab demo.xmI, ftJUftWiPT^f^s <?xml version="l.0" encoding="utf-8"?>

<FrameLayout xmlns:Android-"http://schemas.Android.com/apk/res/Android" Android: layout width-"fill parent" Android:layout_height-"f i1l_parent">

<TextView Android:id=M0+id/viewl"

An dr o i d:ba ckg rou nd="8 d rawa b1e/b1ue" Android:Layout width="fiJ1 parent"

Android:layout height="fill parent" Android: text = "SCMS Tabl fiflfe, "/>

<TextView Android:id="@+id/view2"

Android :background="l?drawable/red" Android:layout width="fill parent" Android:layout height="fillparent" Android: text = "&¥M Tab2, balabalal----0 "/>

<TextView Android:id "@+id/view3"

Androi d:background-"8drawable/green" Android:layout_width="fi11 parent" Android:layout height="fill parent" Android:text "Tab3"/>

</FrameLayout>

'¿wmim 7 3 t Text View Sift. H-tfe» Wife WHIM. Jt ft ft TextView, »J

STinfiiflH 'ft. /li AndroidManifest.xml ifl'f'^jjll TabDemoActivity, JiiSisiT^ttftSH4. ft Wtl »If "Tab View", TabDemoActivity ft % Mill 7-35 Pj\7jk0

• ; CtnOnuMTidnaAtltviiy jar*

• J. lalaPtcfcorAcOvl If Javm

• J I»»c*»t1««Ae<tTil)r. ..»•• « 1 bKAMkilirilrim

« 1 •uotetlntr >•»» « ^ ir»p«ulv&clivll)r jm

• rioTallrtinl; jm

a OB 7-35 TabDemoActivity i, IS 7-36

J' Android 'I'fcttMWWKl Widget Ifflit**Widget glitW

^-fj^^^taiitwii^iiifjii,

SDK iWS API ftWili-fLWMftC», iiifflfniu Android JltftM

0 0

Post a comment