Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 未应用样式材质对话框_Android_Dialog_Styles - Fatal编程技术网

Android 未应用样式材质对话框

Android 未应用样式材质对话框,android,dialog,styles,Android,Dialog,Styles,我试图将自定义样式设置为(材质)对话框,但没有应用,它只显示默认(白色)对话框 我已经查了一些资料,在谷歌上搜索了一下,但不知怎么的,我没有得到我想要的结果 请注意,我是新的造型。如果有人能帮助我,我将不胜感激 多谢各位 MyAlertDialogStyle: <style name="MyAlertDialogStyle" parent="@android:style/Theme.Dialog"> <!-- Used for the buttons -->

我试图将自定义样式设置为(材质)对话框,但没有应用,它只显示默认(白色)对话框

我已经查了一些资料,在谷歌上搜索了一下,但不知怎么的,我没有得到我想要的结果

请注意,我是新的造型。如果有人能帮助我,我将不胜感激

多谢各位

MyAlertDialogStyle:

<style name="MyAlertDialogStyle" parent="@android:style/Theme.Dialog">
   <!-- Used for the buttons -->
   <item name="colorAccent">#FFC107</item>
   <!-- Used for the title and text -->
   <item name="android:textColorPrimary">#FFFFFF</item>
   <!-- Used for the background -->
   <item name="android:background">#4CAF50</item>
</style>
活动显示对话框的地方:

public class ConversationDetailActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<BaseResponse> {

MaterialDialog pd;
..
pd = Utils.createDarkLoadingDialog(this, R.style.MyAlertDialogStyle);
pd.show();
..
}
公共类ConversationDetailActivity扩展BaseActivity实现LoaderManager.LoaderCallbacks{
材料对话;
..
pd=Utils.createDarkLoadingDialog(this,R.style.MyAlertDialogStyle);
pd.show();
..
}

对于有相同问题的人,我使用contextwrapper解决了这个问题

public static MaterialDialog createDarkLoadingDialog(Activity activity) {
        ContextThemeWrapper ctw = new ContextThemeWrapper(activity, R.style.MyAlertDialogStyle);
        return new MaterialDialog.Builder(ctw)
                .title(R.string.loading)
                .content(R.string.wait)
                .progress(true, 0)
                .cancelable(false)
                .build();
    }
然后只需调用/显示活动中的对话框:

pd = Utils.createDarkLoadingDialog(this);
pd.show();

对于有相同问题的人,我使用contextwrapper解决了这个问题

public static MaterialDialog createDarkLoadingDialog(Activity activity) {
        ContextThemeWrapper ctw = new ContextThemeWrapper(activity, R.style.MyAlertDialogStyle);
        return new MaterialDialog.Builder(ctw)
                .title(R.string.loading)
                .content(R.string.wait)
                .progress(true, 0)
                .cancelable(false)
                .build();
    }
然后只需调用/显示活动中的对话框:

pd = Utils.createDarkLoadingDialog(this);
pd.show();