AlertDialog当我添加消息时,有人知道为什么不显示项目列表.setMessage()吗?将显示负面和正面按钮,但不会显示列表.当我删除所有行的行.setMessage().
这是我的代码:
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this.getActivity());
myAlertDialog.setTitle("Options");
myAlertDialog.setMessage("Choose a color.");
CharSequence[] items = {"RED", "BLUE", "GREEN" };
myAlertDialog.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do stuff
}
});
myAlertDialog.setNegativeButton("NO",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do stuff
}
});
myAlertDialog.setPositiveButton("YES",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do stuff
}
});
myAlertDialog.create();
myAlertDialog.show();
Run Code Online (Sandbox Code Playgroud) 你能解释一下为什么这个Dialog不会显示项目吗?
new AlertDialog.Builder(MainActivity.context)
.setTitle("Gestione topic")
.setMessage("Cosa vuoi leggere?")
.setItems(R.array.topicChoices, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//code here
}
}).setNegativeButton("Annulla", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
Run Code Online (Sandbox Code Playgroud)
R.array.topicChoices
<string-array name="topicChoices">
<item>Topic non letti</item>
<item>Risposte non lette</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)
这个bug在哪里?
多谢你们.