how to show that the radio button is selected permanently

穿精又带淫゛_ 提交于 2020-01-07 01:53:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!