我想添加爲中心的兩個單選第二無線電按鈕B下方的按鈕,當我檢查的選項,並點擊驗證,一個動作發生。任何幫助請與單選按鈕對話框和驗證按鈕
final CharSequence[] photo = {"A","B"};
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Select Gender");
alert.setSingleChoiceItems(photo,-1, new
DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
if(photo[which]=="A")
{
gen="B";
}
else if (photo[which]=="B")
{
gen="B";
}
}
});
alert.show();
您應該將您的RadioButtons添加到xml文件中的RadioGroup。 – Kostya 2016-02-25 21:25:22
如何添加onclicklistener – 2016-06-29 09:16:00
@HarishReddy給聽衆: RadioButton rd1 =(RadioButton)dialog.findViewById(R.id.rd_1); rd1.setOnClickListener(new View.OnClickListener(){ @ Override public void onClick(View v){ } }); – davidivad 2016-08-17 15:13:46