android-ui - 单按钮,带有 2个单选按钮,带有 alertdialog

  显示原文与译文双语对照的内容
0 0

我只是想做一个ui应当有一个按钮,单击此按钮时一个对话框,其中有两个可点击单选按钮应该 appear.How 这样的ui?

时间: 原作者:

0 0

用于在按钮单击侦听器中创建警告对话框( 如 this.Call ) 。


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

}

原作者:
...