-1

1つのボタンが表示されるUIを作成したいのですが、このボタンをクリックすると、2つのクリック可能なラジオボタンのあるダイアログが表示されます。このようなUIを作成するにはどうすればよいですか?

4

1 に答える 1

0

このようなアラートダイアログを作成するために使用します。ボタンクリックリスナーでこの方法を呼び出します。

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

}
于 2012-07-14T11:20:40.987 に答える