在我的Android应用程序中,我需要以编程方式使用AlertDialog,并在第一行中使用两个图像,在第二行中使用另外两个图像。我看到了一些示例,例如:
在上面的例子中,每一行只有一个选项,比如第一行是红色,下一行是绿色,第三行是蓝色,我需要在每一行实现两个选项,请指导。
CharSequence colors[] = new CharSequence[] {"red", "green", "blue", "black"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(colors, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// the user clicked on colors[which]
}
});
builder.show();
在上面的例子中,每一行只有一个选项,比如第一行是红色,下一行是绿色,第三行是蓝色,我需要在每一行实现两个选项,请指导。