public void showPopup(int group,int img_index,JSONArray json_ar,View v){
PopupMenu pm=new PopupMenu(EditPhotosActivity.this,v);
pm.getMenuIn
Although I was using AppCompat Theme, but I still had the same problem
I found out that problem is in the declaration of the PopupMenu, and the context I am passing to it.
I was using it like that:
PopupMenu popup = new PopupMenu(getApplicationContext(),v)
But it should be like this:
PopupMenu popup = new PopupMenu(MyActivity.this,v)
I think this might be happening because you are using getBaseContext()
at Toast.makeText
. Try using getApplictaionContext()
or EditPhotosActivity.this
Make sure your have set right theme. android.support.v7.widget.PopupMenu
expect the Application
to have AppCompat
theme, else it will throw exception when you try to show the PopupMenu
android:theme="@style/Theme.AppCompat"
But, android.widget.PopupMenu
will work without this theme.
I had the same issue when creating PopupMenu. I determined that PopupMenu was using:
import android.support.v7.widget.PopupMenu;
The fix was to edit it to:
import android.widget.PopupMenu;