2013-02-14 93 views
0

我有3個按鈕,即修改,查看,清除,我希望它在20個活動中使用。我想重新使用相同,如果在用戶控制在Android? 按鈕1-修改, 按鈕2 - 清除, 按鈕3-視圖。 爲所有人提供共同看法是否好?多次使用相同的按鈕

+2

把它們放入一個片段和重用。 – 323go 2013-02-14 06:21:10

回答

2

你可以將你的3個按鈕保存在另一個佈局layout_button.xml中,然後將它包含在你的活動佈局中,例如: 例如:此烏爾activty佈局:

<?xml version="1.0" encoding="utf-8"?> 

<-- Inflate your other elemnts of ur activity --> 

<include 
    android:layout_width="fill_parent" 
    android:layout_x="0dp" 
    android:layout_y="0dp" 
    layout="@layout/layout_button" />