2011-08-13 28 views
0

我目前正在實施我的儀表板。我對按鈕目前的解決辦法是這樣的:爲儀表板創建按鈕,onClick問題,也許更好的解決方案?

<LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:layout_weight="33" 
         android:gravity="center_horizontal" 
         android:orientation="vertical" 
         android:background="@drawable/button_frame" 
         android:id="@+id/viewAddItemBtn" 
         android:onClick="BtnListener" 
         > 
        <ImageButton 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:background="@drawable/addbutton" 

         /> 
        <TextView 
         android:text="Add Item" 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginTop="5dp" 
         /> 
         </LinearLayout> 

不過,我現在有一些問題1.「可點擊」和各州(聚焦/壓/正常)。 正如你可能猜出我的代碼:如果我點擊「ImageButton」(它可能基本上是一個ImageView解決方案),它什麼都不做。 (因爲onClick沒有被分配,我認爲它會繼承整個LinearLayout的屬性)。第二件事是,如果我讓「ImageButton」可點擊,我猜這些狀態不會被調用,我就在這裏嗎?

對我的設計有沒有更好的解決方案? http://i.imgur.com/aI2Vb.png

回答

2

你爲什麼不添加的onClick屬性的所有組件:按鈕看起來應該像 小演示畫面?

<LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:layout_weight="33" 
         android:gravity="center_horizontal" 
         android:orientation="vertical" 
         android:background="@drawable/button_frame" 
         android:id="@+id/viewAddItemBtn" 
         android:onClick="BtnListener" 
         > 
        <ImageButton 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:background="@drawable/addbutton" 
         android:onClick="BtnListener" 

         /> 
        <TextView 
         android:text="Add Item" 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginTop="5dp" 
         android:onClick="BtnListener" 
         /> 
         </LinearLayout> 
+0

與此不同的狀態 ' \t \t \t <項機器人:抽拉= 「@繪製/幀」/> ' 沒有得到應用 – Aeefire

相關問題