Friday, February 22, 2013

Radio Buttons In Alert Dialog in android


 Radio Buttons In Dialog

 

AlertDialog Radio button;


final CharSequence[] items = {"good "," very good "," nice","soso"};
                
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("Select The Difficulty Level");
                builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                   
                    Intent i=new Intent(getApplicationContext(),SudokuActivity.class);;
                    switch(item)
                    {
                        case 0:
                                // Your code when first option seletced
                                 break;
                        case 1:
                                // Your code when 2nd  option seletced
                                
                                break;
                        case 2:
                               // Your code when 3rd option seletced
                                break;
                        case 3:
                                 // Your code when 4th  option seletced                        
                                 break;
                        
                    }
                    levelDialog.dismiss();    
                    }
                });
                levelDialog = builder.create();
                levelDialog.show();


put your code in  java file then see the output.

Thank you.

No comments:

Post a Comment