I'm building a project based on the existing SO question custom row in a listPreference?. In my version of the program, selecting radio buttons does not work; the last checked item doesn't get saved. My simulated project is here, and has a black background.
Asked
Active
Viewed 556 times
1 Answers
1
do these changes(part of codes):
public void onClick(View v)
{
for(RadioButton rb : rButtonList)
{
if(rb.getId() != position)
rb.setChecked(false);
}
int index = position;
String value = entryValues[index].toString();
editor.putString("yourPref", value);
editor.commit();
Dialog mDialog = getDialog();
mDialog.dismiss();
CustomHolder(View row, int position)
{
text = (TextView)row.findViewById(R.id.custom_list_view_row_text_view);
text.setText(entries[position]);
rButton =(RadioButton)row.findViewById(R.id.custom_list_view_row_radio_button);
rButton.setId(position);
if(entryValues[position].toString().equalsIgnoreCase(FontSize))
{
rButton.setChecked(true);
}
if(isChecked)
{
for(RadioButton rb : rButtonList)
{
if(rb != buttonView)
rb.setChecked(false);
}
int index = buttonView.getId();
String value = entryValues[index].toString();
editor.putString("yourPref", value);
editor.commit();
and FontSize variable fill in constructor:
SharedPreferences fontsizesetting = PreferenceManager.getDefaultSharedPreferences(context);
String temp = fontsizesetting.getString("yourPref","16");

CooL i3oY
- 790
- 1
- 9
- 26
-
Hey, If I am implementing it for more than one listPreferences, how can I get the `"key"` as here it is hard coded as `"yourPref"`? – impossible Jul 13 '16 at 11:02