天天看点

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qingfeng812/article/details/70916119

异常名称

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

日志截图:

根据友盟闪退日志截图:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant

原因归纳

有同事把.Builder()中的Context写成了getApplicationContext()引发的错误

正确写法需要传递当前activity的Context对象。而不是全局的Context。

正确写法:

new AlertDialog
                        .Builder(PlatWDdetailyActivity.this)
                        .setTitle("温馨提示")
                        .setMessage("\t\t确认反提交该条单据?")
                        .setNegativeButton("取消", null)
                        .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String retype = "reforsub";
                                doresubmit(retype);
                            }
                        }).show();
           

继续阅读