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
You are encountering this error because your AlertDialog
is not using AppCompat theme while your activity is. To fix it, use the this
property of your activity instead of getApplicationContext()
, like so:
AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this);
The name of your activity, followed by .this
, in this case DialogActivity.this
, should always be used instead of only this
, because if your dialog is created inside another class, for example an adapter of some sort, you will receive a compile-time error stating that a Context
was expected instead of the adapter class given.