@cxm-2016
2016-08-11T17:31:16.000000Z
字数 1057
阅读 1511
android
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/abc_1" android:state_checked="true" />
<item android:drawable="@drawable/abc_2" android:state_checked="false" />
</selector>
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<RadioButton
android:id="@+id/s1"
style="@style/avatar_main"
android:background="@drawable/selector_1" />
<RadioButton
android:id="@+id/s2"
style="@style/avatar_main"
android:background="@drawable/selector_2" />
<RadioButton
android:id="@+id/s3"
style="@style/avatar_main"
android:background="@drawable/selector_3" />
</RadioGroup>
radioGroup.setOnCheckedChangeListener { view, i ->
when (view.checkedRadioButtonId) {
R.id.s1 -> {
showFragment(R.id.frame_layout, Fragment1::class.java)
}
R.id.s2 -> {
showFragment(R.id.frame_layout, Fragment2::class.java)
}
R.id.s3 -> {
showFragment(R.id.frame_layout, Fragment3::class.java)
}
}
}