开发者

How to add listener on alert dialog box with customised radio button in android

开发者 https://www.devze.com 2023-03-17 18:35 出处:网络
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.

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消