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