我想做爲的UITabBarController確實在iPhone, 我有四節課,我想在一個焊接設備Android中一個tabber中的四個類?
工作他們爲我點擊第一個選項卡,頭等艙應顯示 我點擊第二個選項卡,第二類應該顯示 我點擊第三個標籤,第三類應該顯示 我點擊fouth標籤,第四類應顯示
什麼是最好的,簡單的方法以這樣的條件下操作, 我是新來的Android的研究與開發,這是我的第一個應用程序 如果你不清楚問題,可以再問一次...
我想做爲的UITabBarController確實在iPhone, 我有四節課,我想在一個焊接設備Android中一個tabber中的四個類?
工作他們爲我點擊第一個選項卡,頭等艙應顯示 我點擊第二個選項卡,第二類應該顯示 我點擊第三個標籤,第三類應該顯示 我點擊fouth標籤,第四類應顯示
什麼是最好的,簡單的方法以這樣的條件下操作, 我是新來的Android的研究與開發,這是我的第一個應用程序 如果你不清楚問題,可以再問一次...
安卓開發網站有一個你正在尋找的例子。 http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
有代碼示例。你需要做一個標籤佈局xml文件,編輯main.xml中,然後在Java代碼中,爲每個標籤你就會有這樣的事情
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent);
tabHost.addTab(spec);
這是實現標籤欄的Java代碼在Android的
tabHost = getTabHost(); // The activity TabHost
tabHost.setOnTabChangedListener(this);
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
TabSpec thirdTabSpec = tabHost.newTabSpec("tid3");
TabSpec fourthTabSpec = tabHost.newTabSpec("tid4");
TabSpec fifthTabSpec = tabHost.newTabSpec("tid5");
viewCache[0] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[1] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[2] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[3] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[4] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
firstTabSpec.setIndicator(viewCache[0]);
secondTabSpec.setIndicator(viewCache[1]);
thirdTabSpec.setIndicator(viewCache[2]);
fourthTabSpec.setIndicator(viewCache[3]);
fifthTabSpec.setIndicator(viewCache[4]);
firstTabSpec.setContent(new Intent(this, HomeTabActivityGroup.class));
secondTabSpec
.setContent(new Intent(this, ProfileTabActivityGroup.class));
thirdTabSpec.setContent(new Intent(this,
NotificationTabActivityGroup.class));
fourthTabSpec.setContent(new Intent(this,
FavoritesTabActivityGroup.class));
fifthTabSpec
.setContent(new Intent(this, MoreTabActivityGroupNew.class));
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
tabHost.addTab(thirdTabSpec);
tabHost.addTab(fourthTabSpec);
tabHost.addTab(fifthTabSpec);
// * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * * 這是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">
<RelativeLayout
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_alignParentBottom="true"
android:layout_height="wrap_content"
tabStripEnabled = "false"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_alignParentTop="true"
android:layout_above="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
// * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * * 這是Tab1.xml的XML男女同校的標籤佈局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content"
android:layout_height="50dip"></ImageView>
</LinearLayout>
「當我點擊第一個標籤時,第一類應該顯示爲我點擊第二個標籤,第二級的顯示爲我點擊第二個標籤,第二個類別的顯示爲我點擊第二個標籤,第二個類別的顯示」 - 這是明確的肯定,因爲你已經重複了3次 – Egor
現在閱讀這個問題,我編輯 –