0
我正在基于现有SO问题custom row in a listPreference?构建项目。在我的程序版本中,选择单选按钮不起作用;上次检查的项目不会被保存。我的模拟项目是here,并且有黑色背景。Custom ListPreference RadioButton不保存所选项目
我正在基于现有SO问题custom row in a listPreference?构建项目。在我的程序版本中,选择单选按钮不起作用;上次检查的项目不会被保存。我的模拟项目是here,并且有黑色背景。Custom ListPreference RadioButton不保存所选项目
做这些改变(代码部分):
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();
和字号可变填写构造函数:
SharedPreferences fontsizesetting = PreferenceManager.getDefaultSharedPreferences(context);
String temp = fontsizesetting.getString("yourPref","16");
嘿,如果我实现它多于一个listPreferences,我怎么能得到的''钥匙''在这里它被硬编码为''yourPref“'? – impossible
那你的代码?我们应该猜测吗? – alfasin