天天看點

AlertDialog5種預設Theme對應的樣式

Dialog alertDialog = new AlertDialog.Builder(this,AlertDialog.THEME_TRADITIONAL)
				.setTitle(R.string.msg_dialog_title)
				.setPositiveButton("确定", null)
				.setNegativeButton("取消", null)
				.setItems(list.toArray(new String[list.size()]),
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								et.setText(list.get(which));
								et.setSelection(et.getText().length());
							}
						}).create();
		alertDialog.show();
           

Builder(this,AlertDialog.THEME_TRADITIONAL)中第二個參數可以設定不同的Theme

AlertDialog.THEME_HOLO_DARK

AlertDialog.THEME_HOLO_LIGHT

以上兩種見下圖,分别為深色/淺色

AlertDialog5種預設Theme對應的樣式

AlertDialog.THEME_DEVICE_DEFAULT_DARK

AlertDialog.THEME_DEVICE_DEFAULT_LIGHT

以上兩種見下圖,分别為深色/淺色

AlertDialog5種預設Theme對應的樣式