What I am trying to accomplish is a dialog preference that I have my own layout in. My layout is just a radiogroup with 4 radio buttons. The problem I am having is I am not sure in which method of my DialogPreference.java file I can actually do things with the radio buttons in (meaning tell which one is selected and then save that value to shared preferences). Currently my DialogPreference. java looks like:
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
}
}
}
When the dialog opens it shows the layout correctly, but I just need assistance as to where to put the code to make use of the radio buttons.
将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 } }
中@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 } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.