Tib*_*ion 1 android themes android-alertdialog
如何将警报主题设置为标准Android主题之一?我想使用Holo Dark,因为弹出窗口默认为Holo Light。我的代码:
AlertDialog.Builder confirm = new AlertDialog.Builder(this);
confirm.setTitle("Confirm");
confirm.setMessage("Confirm and set delay?");
confirm.setCancelable(false);
confirm.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startDelay();
}
});
confirm.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
confirm.show();
Run Code Online (Sandbox Code Playgroud)
v7库android.support.v7.app.AlertDialog的主题
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(this,R.attr.alertDialogTheme);
Run Code Online (Sandbox Code Playgroud)
带有用于android.app.AlertDialog的构造方法的主题
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this,AlertDialog.THEME_HOLO_LIGHT );
Run Code Online (Sandbox Code Playgroud)
但是根据新文档,
此常量(AlertDialog.THEME_HOLO_LIGHT)在API级别23中已弃用。使用Theme_Material_Light_Dialog_Alert。
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this,android.R.style.Theme_Material_Light_Dialog_Alert );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5797 次 |
| 最近记录: |