I am trying to add customised radio button in alert dialog box. Now I want to add listener on that. I have tried to add listener using Radio group but it shows null pointer exception. This is my code. Please how to add listener whereby I want to dismiss the dialog box on clicking any of the radio buttons
final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
LayoutInflater eulaInflater = LayoutInflater.from(this);
View eulaLayout = eulaInflater.inflate(R.layout.alertdialogcustom, null);
alt_bld.setView(eulaLayout);
R开发者_开发技巧adioGroup rgroup = (RadioGroup)findViewById(R.id.group1);
Thanks Astha
I got it myself using Dialog
dialog.setContentView(R.layout.alertdialogcustom);
dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
final RadioGroup rgroup = (RadioGroup)dialog.findViewById(R.id.group1);
final RadioButton rbutton_series = (RadioButton) dialog.findViewById(R.id.option1);
final RadioButton rbutton_overlay = (RadioButton) dialog.findViewById(R.id.option2);
rgroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
精彩评论