Use either getActivity()
or v.getContext()
instead of this
. Since you are inside of an OnClickListener
(Anonymous inner class) this
refers to the OnClickListener
instead of the proper Context
. Try something like
AlertDialog.Builder PUHelpBuilder = new AlertDialog.Builder(v.getContext());
You need a Context
for getLayoutInflater()
also since it is an Activity
method so try the same thing
v.getContext().getLayoutInflater();
Edit
Look at the Activity Docs...it extends Context
which means it has it's own Context
and is why you can use this
when inside of an Acitivity
method. But as I said, in your onClick()
you are actually inside of an anonymous inner-class so this
no longer refers to the Activity Context
.