layout---「activity_store_unit.xml」的內容
================================================
================================================
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/TabHost1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EF7B2F"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".StoreProdListActivity" >
<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:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
==============================================
*.java
============================================
package com.neo_tech.goingtvmall.frontend;
import android.os.Bundle;
import android.app.Activity;
import android.app.LocalActivityManager;
import android.app.TabActivity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
public class StoreUnitActivity extends Activity {
//extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_store_unit);
TabHost tabHost=(TabHost)findViewById(R.id.TabHost1);
//tabHost.setup();
LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false);
mLocalActivityManager.dispatchCreate(savedInstanceState);
tabHost.setup(mLocalActivityManager);
TabSpec tbs=tabHost.newTabSpec("tab1");
tbs.setIndicator("店家資訊");
tbs.setContent(new Intent(this,
StoreIntroductionActivity.class ));
try{
tabHost.addTab(tbs);
tabHost.addTab(
tabHost.newTabSpec("tab2").setIndicator("有什麼產品呢?").setContent(new Intent(this,
StoreProdListActivity.class ))
);
tabHost.addTab(
tabHost.newTabSpec("tab3").setIndicator("選了什麼?").setContent(new Intent(this,
StoreCartActivity.class ))
);
}catch(Exception exp){
exp.printStackTrace();
Log.e("error",exp.getMessage());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.store_unit, menu);
return true;
}
}
================================================
沒有留言:
張貼留言