问题
i have the same problem as how to show the radio button is selected is still ticked? but in android platform... can anybody help me please.. my codes are
<RadioButton
android:checked="false"
android:id="@+id/BBC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffff6600"
android:text="BBC NEWS"
android:typeface="serif"
android:textStyle="bold"
android:layout_x="10px"
android:layout_y="100px">
</RadioButton>
Thanks in advance...
回答1:
A question with similar content was asked yesterday:
I have radio button for the user to choose if he/she wants to keep his/her account logged in.
you can't solve this problem just with the layout.xml - you need to save the status of the radio button and load it again once the appropriate activity is started
回答2:
You could save the value (when changed) to SharedPreferences, read it each time the page is loaded, and set the checked state based on that.
回答3:
You can use a static variable like is_ticked & set its value true/false when user tick it. and check value of this variable in onCreate() if(is_ticked) set radio button to checked else unchecked .
回答4:
You could use this:
mListView.setItemChecked(selectedPosition, true);//this will check(enable) the desired radio button.
selectedPosition, you can save using SharedPreferences.
来源:https://stackoverflow.com/questions/7334106/how-to-show-that-the-radio-button-is-selected-permanently