我想在我的libGDX項目中顯示「確認出口」Holo對話框。這是我的代碼:Android Holo主題與libGDX的Android對話框看起來很奇怪
@Override
public void onBackPressed() {
AlertDialog.Builder bld;
if (android.os.Build.VERSION.SDK_INT <= 10) {
//With default theme looks perfect:
bld = new AlertDialog.Builder(AndroidLauncher.this);
} else {
//With Holo theme appears the double Dialog:
bld = new AlertDialog.Builder(AndroidLauncher.this, android.R.style.Theme_Holo_Dialog_MinWidth);
}
bld.setIcon(R.drawable.ic_launcher);
bld.setTitle("Exit");
bld.setMessage("Are you sure you want to exit?");
bld.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }
});
bld.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { finish(); }
});
bld.setCancelable(false);
bld.create().show();
}
對話框工作,但與全息主題出現一個醜陋的背景。
這是結果,與非霍洛主題:
而醜陋的結果與霍洛主題:
我如何能表現出全息對話框,而不醜陋的「雙人對話」?謝謝!的
可能類似的問題:https://github.com/Prototik/HoloEverywhere/issues/199 – moujib 2014-09-01 22:14:59
,這可能包含一個解決方案:http://stackoverflow.com/questions/15125220/android-holo-dialog-has-2-backgrounds-layered-on-top-of-one-another – moujib 2014-09-01 22:15:47
謝謝moujib! ContextThemeWrapper解決了問題! – 2014-09-01 22:22:18