setSingleChoiceItems时传入-1即可。 private void showKeyWordsDialog(final String answer, final EditText et) { final String[] keywords = (String[])mCurrentItem.getCombinations().toArray(); AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogInterface.OnClickListener onWorDClicked = new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String word = keywords[which]; et.setText(word); } }; builder.setTitle("请选择正确答案"); builder.setIcon(R.drawable.ic_launcher); builder.setSingleChoiceItems(keywords, -1, onWorDClicked); builder.setPositiveButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); mKeywordsDialog = builder.create(); mKeywordsDialog.show(); }(责任编辑:好模板) |