2011-10-24 77 views
0

我在一個應用程序中工作,我在底部有一個專用菜單,其中包含一些固定按鈕,它們具有相同的功能,並且在所有活動中的行爲相同。 我嘗試在不同的活動中使用相同的按鈕ID(視圖)的ID,但它不工作。我也搜索了很多沒有找到任何方式 是否有任何方式可以在多個活動中共享視圖或視圖組?例如,我創建此佈局一次又一次使用相同的VIEW(Android)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/parentLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/childLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" android:layout_weight="1" > 
    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button1" android:layout_weight="1"/> 
    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button2" android:layout_weight="1"/> 
</LinearLayout></LinearLayout> 

是有任何方式,這種佈局ID =「childLayout」可在其佈局ID =內部「parentLayout」

回答

1

任何其它活動中使用

你有沒有試過按照建議here

+0

謝謝,它真的幫了很多 – ammar26

相關問題