Ich habe ein Problem, ich kann die Textfarbe nicht ändern, wenn RadioButton ausgewählt ist. Ich habe dies in activity.xmlFarbtext einstellen RadioButton hat RadioGroup mit benutzerdefinierter Form eingecheckt
<RadioGroup
android:id="@+id/activity_onsite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<RadioButton
android:id="@+id/onsite_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:background="@drawable/toggle_btn"
android:padding="10dp"
android:text="office"
android:button="@null"/>
<RadioButton
android:id="@+id/onsite_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toggle_btn"
android:text="clients"
android:padding="10dp"
android:button="@null"/>
</RadioGroup>
in meine Ressourcen @ ziehbar/togglebtn Ich habe
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_btn_selected" android:state_checked="true" />
<item android:drawable="@drawable/radio_btn_regular" android:state_checked="false"/>
</selector>
Und schließlich in meinem @ ziehbar/radio_btn_selected
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:radius="5dp" />
<solid
android:color="#39b3d7"
/>
<stroke
android:width="1dp"
android:color="#269abc" />
</shape>
Und in @ ziehbar/radio_btn_regular
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:radius="5dp" />
<solid
android:color="#fff"
/>
<stroke
android:width="1dp"
android:color="#269abc" />
</shape>
Kann ich Textfarbe in radio_btn_selected.xml ändern?
Sie benutzerdefinierte Farbwähler erstellen und die Textfarbe mit diesem Set – lal
http://stackoverflow.com/a/3565624/3092341 das kann Ihnen helfen – lal