How can I fix this error: You need to use a Theme.AppCompat theme (or descendant) with this activity

后端 未结 6 1653
醉梦人生
醉梦人生 2021-02-07 09:36

I searched all internet web sites to fix this error, but I couldn\'t. I just want to create AlertDialog with two button Yes and No.

This is my code:

impo         


        
6条回答
  •  轮回少年
    2021-02-07 10:19

    If you have another styles files in side another values folders like "values-v11", "values-v14"... Edit theme also and try to clean your app before running.

    Edited: From your activity change getApplicationContext() to this:

    AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
    

    to

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    

    Because the dialog also should extends the Appcompat Theme.

提交回复
热议问题