In android, by using dialog we can select a option from multiple option using radio buttons.
Example for Dialog with select option :-
The output will looks like

Example for Dialog with select option :-
public class ExampleApp extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String items[] = {"item1","item2","item3"};
AlertDialog.Builder ab=new AlertDialog.Builder(ExampleApp.this);
ab.setTitle("Title");
ab.setSingleChoiceItems(items, 0,new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// onClick Action
}
})
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// on Ok button action
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// on cancel button action
}
});
ab.show();
}
}
The output will looks like

0 comments
Thanks for your comment