![](/img/trans.png)
[英]Show AlertDialog “on top of” DialogPreference when ok is clicked
[英]AlertDialog and DialogPreference
我在警报对话框中有此功能,效果很好
ContextThemeWrapper ctw = new ContextThemeWrapper( MvcnContactList.this, R.style.MyTheme );
alertDialogBuilder = new AlertDialog.Builder(ctw);
//set some views and onclick listeners
alertDialog = alertDialogBuilder.create();
alertDialog.setCancelable(false);
alertDialog.show();
但是我有一个关于首选项对话框,并且我希望该对话框具有与我的警报对话框相同的阶梯。 但是我不知道将这种样式应用于对话框很热
public class About extends DialogPreference {
public AboutDialog(Context oContext, AttributeSet attrs)
{
super(oContext, attrs);
}
}
注意:我将android:style =“ @ style / impex_dialog”放在我的pref.xml文件中,并且无法识别此样式标签。
警报对话框使用:
com.android.internal.R.style.Theme_Dialog_Alert
从Android来源:
protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, com.android.internal.R.style.Theme_Dialog_Alert);
setCancelable(cancelable);
setOnCancelListener(cancelListener);
mAlert = new AlertController(context, this, getWindow());
}
所以我想您应该尝试这样的事情,因为它在themes.xml
定义:
<!-- Default theme for alert dialog windows, which is used by the
{@link android.app.AlertDialog} class. This is basically a dialog
but sets the background to empty so it can do two-tone backgrounds. -->
<style name="Theme.Dialog.Alert" parent="@android:style/Theme.Dialog">
<item name="windowBackground">@android:color/transparent</item>
<item name="windowTitleStyle">@android:style/DialogWindowTitle</item>
<item name="windowIsFloating">true</item>
<item name="windowContentOverlay">@null</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.