I use appcompat v22.1.0 in my App and use Toolbar. Everything was fine when I use Theme.AppCompat.Light.NoActionBar
. When I start implement AlertDialog
If you are using support library your activity extends AppCompactActivity
, if you use android studio
to create activity this is default. In such case pass context to the builder as ActivityName.this
or simply this
if you are passing it in onCreate
, passing getApplicationContext()
will not work.
This is my style using appcompact
And everything is working fine when I use this
or ActivityName.this
as mentioned above (here ActivityName is the name of your current activity i.e. MainActivity.this
).
If you are using in fragment you should pass getActivity()
as context to builder instead of getContext()
.