Android AlertDialog和DialogPreference
我有这个警报对话框,这是完美的Android AlertDialog和DialogPreference,android,dialog,preferences,android-dialog,android-gui,Android,Dialog,Preferences,Android Dialog,Android Gui,我有这个警报对话框,这是完美的 ContextThemeWrapper ctw = new ContextThemeWrapper( MvcnContactList.this, R.style.MyTheme ); alertDialogBuilder = new AlertDialog.Builder(ctw); //set some views and onclick listeners alertDialog = alert
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\u 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>
@android:彩色/透明
@android:style/DialogWindowTitle
符合事实的
@空的