How To Show Alertdialog When Clicking On Button In Item In List View
I have tried the following code .. btnRemoveItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg
Solution 1:
AlertDialogs can only be created using Activity contexts, so getApplicationContext() will not work. Instead, add the following global variable to your Activity file:
Context mContext;
And then add the following to your onCreate():
mContext = this;
Now, change:
AlertDialog.Builderbuilder=newAlertDialog.Builder(getApplicationContext());
to
AlertDialog.Builderbuilder=newAlertDialog.Builder(mContext);
Solution 2:
You're using getApplicationContext() when you should be using the activity context use SearchActivity.this instead
Post a Comment for "How To Show Alertdialog When Clicking On Button In Item In List View"