我正在使用以下代码创建一个 AlertDialog
CharSequence[] array = {"Font1", "Font2", "Font3", "Font4"};
callback = (DialogClickListener) fragment;
builder = new AlertDialog.Builder(context);
builder.setTitle("Font Settings")
.setSingleChoiceItems(array, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
selected = array[arg1].toString();
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
})
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
callback.onYesClick(selected);
}
});
如何设置默认选择的元素?请帮忙 :)