Which Context Do I Need?
I'm creating a dialog box and using the (this) isnt working. Up until now its just been a button calling a dialogbox but now the button within the called dialogbox needs to call an
Solution 1:
getApplicationContext()
or use YourActictyName.this
Because this
refers the button click listner
,not your class Object
Solution 2:
If this code is in the onCreate()
method, or similiar, add getApplicationContext()
instead of this
and you should be fine. That's because this
in a Button-context will refer to the button environment.
Post a Comment for "Which Context Do I Need?"