0

我想要完成的是一个对话框首选项,我有自己的布局。我的布局只是一个带有 4 个单选按钮的单选组。我遇到的问题是我不确定在 DialogPreference.java 文件的哪个方法中我实际上可以使用单选按钮执行操作(意思是告诉选择了哪个,然后将该值保存到共享首选项)。目前我的 DialogPreference。java看起来像:

public class DialogPreferences extends DialogPreference implements RadioGroup.OnCheckedChangeListener
{

RadioGroup group;
public DialogPreferences(Context oContext, AttributeSet attrs)
{
    super(oContext, attrs);
    setDialogLayoutResource(R.xml.imagechoice);

}


@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
     //I would like to do things here but when I try to for example add the reference to a radio button it gives cannot resolve method findViewById error
    }
}
}

当对话框打开时,它会正确显示布局,但我只需要有关将代码放在何处以使用单选按钮的帮助。

4

1 回答 1

0

将 RadioGroup 的工作放在 @Override public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { //I would like to do things here but when I try to for example add the reference to a radio button it gives cannot resolve method findViewById error } }

于 2014-02-12T02:10:23.277 回答