0

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.

ez4nick
  • 9,756
  • 12
  • 37
  • 69
  • Try posting the code you are trying and the error it gives. Also a [MCVE](http://stackoverflow.com/help/mcve) might help in this case. – Java Devil Feb 12 '14 at 01:21

1 Answers1

0

Puting the RadioGroup's work in @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 } }

Andy.Zhao
  • 250
  • 3
  • 16
  • The problem is that when I try to reference a radiobutton it tells me "cannot resolve method findViewById)/ thats where I am having the issue – ez4nick Feb 12 '14 at 02:45
  • @ez4nick you should use View.findViewById(),just like that View view = inflater.inflate(R.layout.fenlei_item, null); itemImage = (ImageView)view.findViewById(R.id.fenlei_item_image); – Andy.Zhao Feb 12 '14 at 03:40