用radiogroup
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/left"></item>
<item android:drawable="@drawable/ic_launcher"></item>
</selector>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/tab_item_bg"/>
变换checked的状态
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/khss_yhm_btn"
style="@style/groupbutton_left"
android:text="@string/yhm"
android:checked="true"
android:onClick="select_type" />
<RadioButton
android:id="@+id/khss_zjzh_btn"
style="@style/groupbutton_right"
android:text="@string/khss_zjzh"
android:onClick="select_type"/>
</RadioGroup>
<style name="groupbutton_left">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/button_group_left</item>
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/white</item>
</style>