-1

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?

K_Anas
  • 31,226
  • 9
  • 68
  • 81
Naseeb Sheoran
  • 423
  • 2
  • 8
  • 21

1 Answers1

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