我正在使用 alertDialog 来显示类似于微调器的数据。有没有办法使用 setItems 移动活动选择(如在 setSingleChoice 中)?
我希望显示的列表看起来像一个微调器,没有单选按钮。
我正在使用 alertDialog 来显示类似于微调器的数据。有没有办法使用 setItems 移动活动选择(如在 setSingleChoice 中)?
我希望显示的列表看起来像一个微调器,没有单选按钮。
从 Android API查看此页面。您可以创建要显示的项目列表。数组长度可以任意长。当项目数量足够大时,列表将滚动。非常像陀螺。
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();