RadioGroup和RadioButton

RadioGroup和RadioButton分别是单选按钮组和单选按钮
一个单选按钮组中可以有多个单选按钮且只能有一个单选按钮被选中
界面代码:

<RadioGroup android:id="@+id/main_tab" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_alignParentBottom="true" android:layout_height="60dip">  
    <RadioButton  style="@style/main_tab" android:id="@+id/tab_shoujian" <!--图片在文字的上方-->  
            android:drawableTop="@drawable/tab_shoujian_selector"
            android:layout_height="match_parent"
            android:checked="true" 
            android:text="text1" />  
        <RadioButton  style="@style/main_tab" android:id="@+id/tab_me" android:drawableTop="@drawable/tab_me_selector" android:layout_height="match_parent" android:text="text2" /> 
</RadioGroup> 

样式代码:tab_shoujian_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">  
    //单选按钮选中状态 
    <item android:drawable="@drawable/tag_main_order_pressed_48" android:state_checked="true" /> 
    <item android:drawable="@drawable/tag_main_order_pressed_48" android:state_pressed="true" />   
    //单选按钮未选中状态
    <item android:drawable="@drawable/tag_main_order_48" />  
</selector> 

样式代码:tab_me_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    //单选按钮选中状态 
    <item android:drawable="@drawable/tag_main_me_pressed_48" android:state_pressed="true"/>  
    <item android:drawable="@drawable/tag_main_me_pressed_48" android:state_checked="true"/>
    //单选按钮未选中状态  
    <item android:drawable="@drawable/tag_main_me_48" />  
</selector> 

你可能感兴趣的:(android,RadioButto)