问题
I have created a layout which consist of three buttons in linear layout. Whenever i click on any other controls the text in the button changes. Please see the layout given below:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TableRow android:id="@+id/TableRow01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/list_select">
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/set"
android:text="@string/button_settings_done"
android:layout_marginTop="@dimen/button_settings_margin_top"
android:onClick="hello()"
android:gravity="center"
android:textColor="@color/buttonColor"
android:textStyle="bold"
android:typeface="serif" android:layout_gravity="center" android:layout_weight="1">
</Button>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_settings_cancel"
android:id="@+id/cancel"
android:layout_marginTop="@dimen/button_settings_margin_top"
android:gravity="center"
android:textColor="@color/buttonColor"
android:textStyle="bold"
android:typeface="serif" android:layout_gravity="center" android:layout_weight="1"></Button>
<Button
android:id="@+id/delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/button_settings_margin_top"
android:text="@string/button_settings_delete"
android:gravity="center"
android:textColor="@color/buttonColor"
android:textStyle="bold"
android:typeface="serif"
android:layout_gravity="center" android:layout_weight="1"/>
enter code here
来源:https://stackoverflow.com/questions/9331640/text-in-button-changing-on-clicking-other-controls