I just want to make a UI in which one button should be there,when this button is clicked a dialog with two clickable radio buttons should appear.How to make such UI?
Asked
Active
Viewed 159 times
1 Answers
0
Use to create alert dialog like this.Call this methos in your button click listener.
private void showDialog() {
final CharSequence[] Countries = { "India", "U.S.A", "U.K" };
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setIcon(R.drawable.icon);
alt_bld.setTitle("Select Country");
//you can set the Default selected value of the list, Here it is 0 means India
alt_bld.setSingleChoiceItems(Countries, 0,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getBaseContext(), Countries[item],
Toast.LENGTH_LONG).show();
alert.cancel();
}
});
alert = alt_bld.create();
alert.show();
}

Shalini
- 1,733
- 4
- 17
- 31
-
please tell me how to implement 2 radio buttons within that alert dialog – Naseeb Sheoran Jul 14 '12 at 11:22
-
The above code having three radio button such as India,U.S.A. and U.k. Just run these you get idea after that – Shalini Jul 14 '12 at 11:23