2010-12-13 33 views
0

我想在Android中有一個共同的底部欄。如果任何按鈕被點擊,那麼它應該打開新的活動,底部欄仍然在底部。有什麼辦法可以做到這一點?我曾嘗試過在底部有4個按鈕的超類,然後在點擊事件中打開新的活動,但我不知道爲什麼底部欄不顯示,這是正確的方法嗎?Android上的底欄與上面的不同佈局?

回答

1

我這樣做的方式是有一個單獨的Activity,它由佔據大部分窗口的ViewFlipper和底部的按鈕欄組成。孩子的「活動」僅僅是ViewFlipper的孩子。工作很好。

實例後來補充:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
> 
    <ViewFlipper 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
    > 

    <!-- Your pages go here, i.e.: --> 
    <include android:id="@+id/page1" layout="@layout/page1" /> 
    <include android:id="@+id/page2" layout="@layout/page2" /> 
    ... 

    </ViewFlipper> 

    <!-- Your bottom bar --> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
    > 
    ... buttons or whatever you want here ... 
    </LinearLayout> 

</LinearLayout> 
+0

我嘗試添加在viewflipper的觀點,但不會出現在屏幕上。你能讓我知道該怎麼做嗎? – sunil 2010-12-14 09:55:15

+0

我會更新我的答案。 – 2010-12-14 10:18:07