我有两个单选按钮作为单选组,还有一个“执行”按钮 - 因此您选择单选按钮,点击“执行”,它会根据单选选项显示备用对话框。我在倒数第二行(创建警报对话框生成器)中收到以下错误:
private OnClickListener myClickcalcHandler = new OnClickListener() {
public void myClickcalcHandler(View view) {
switch (view.getId()) {
case R.id.calcbutton:
RadioButton insideButton = (RadioButton) findViewById(R.id.radioButton1);
RadioButton outsideButton = (RadioButton) findViewById(R.id.radioButton1);
}
if
(outsideButton.isChecked()){
//do what you want
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("some outside activity");
button = (Button) findViewById(R.id.emailbutton);
// set dialog message
alertDialogBuilder
.setMessage(R.string.email_long)
.setCancelable(false)
.setNegativeButton("Close",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
}
else if
(insideButton.isChecked()){
//do what you want
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("some inside activity");
button = (Button) findViewById(R.id.emailbutton);
// set dialog message
alertDialogBuilder
.setMessage(R.string.email_long)
.setCancelable(false)
.setNegativeButton("Close",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
}
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
所以eclipse编辑器只是说“alertDialogBuilder无法解决”,我不知道为什么。