ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    카테고리 없음 2021. 4. 27. 14:50

    import android.support.v7.app.AlertDialog된 상황에서는 아래가 맞지만

     

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getApplicationContext());
    alertDialog.setTitle("내용이 삭제되었습니다");
    alertDialog.setPositiveButton("확인", (dialogInterface, i) -> finish());
    alertDialog.show();

     

     

     

    import androidx.appcompat.app.AlertDialog;

    가 들어가 있는 경우에는 위 에러가 발생.

     

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getApplicationContext(),R.style.Theme_AppCompat_Dialog_Alert);//테마를 지정
    alertDialog.setTitle("내용이 삭제되었습니다");
    alertDialog.setPositiveButton("확인", (dialogInterface, i) -> finish());
    alertDialog.show();

     

     

    당연히 impot를 v7.dialog를 사용하거나, 앱 테마를 따로 AndroidManifest.xml에 가서 해당 엑티비티에 

    지정해줘도 풀린다.

    어쨋든 앱 테마가 맞지 않아서 발생하는 버그이다.

    댓글

Designed by Tistory.