title: Unable to show popup menu in Adapter in Android
body: <p>I am developing an Android app. In my app, I am showing pop up menu in Recycler view adapter. But it is giving me error.</p>
  
  <p>In onBindViewHolder of RecyclerViewAdapter, I am showing pop up menu like this</p>
  
  <pre><code>viewHolder.container.setOnLongClickListener(new View.OnLongClickListener() {
              @Override
              public boolean onLongClick(View view) {
                  PopupMenu popupMenu = new PopupMenu(context,view);
                  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                      @Override
                      public boolean onMenuItemClick(MenuItem item) {
                          return false;
                      }
                  });
                  popupMenu.inflate(R.menu.menu_mm_comment_item);
  
                  popupMenu.show();
                  return true;
              }
  </code></pre>
  
  <p>But when I fire long click event, it is giving me this error.</p>
  
  <blockquote>
    <p>FATAL EXCEPTION: main
                                                                                                          Process: com.tonightfootball.waiyanhein.tonightfootballreport, PID:
    28052
                                                                                                          android.view.InflateException: Binary XML file line #17: Failed to
    resolve attribute at index 6: TypedValue{t=0x1d/d=0xff5c5cff a=1
    r=0x106002f}
                                                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                                                              at
    android.support.v7.view.menu.MenuAdapter.getView(MenuAdapter.java:93)
                                                                                                              at
    android.support.v7.view.menu.MenuPopup.measureIndividualMenuWidth(MenuPopup.java:160)
                                                                                                              at
    android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:153)
                                                                                                              at
    android.support.v7.view.menu.StandardMenuPopup.show(StandardMenuPopup.java:187)
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.showPopup(MenuPopupHelper.java:290)
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:175)
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.show(MenuPopupHelper.java:141)
                                                                                                              at android.support.v7.widget.PopupMenu.show(PopupMenu.java:233)
                                                                                                              at
    com.tonightfootball.waiyanhein.adapter.MemeCommentsAdapter$1.onLongClick(MemeCommentsAdapter.java:113)
                                                                                                              at android.view.View.performLongClick(View.java:5237)
                                                                                                              at android.view.View$CheckForLongPress.run(View.java:21121)
                                                                                                              at android.os.Handler.handleCallback(Handler.java:739)
                                                                                                              at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                                                              at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                                           Caused by: java.lang.UnsupportedOperationException: Failed to resolve
    attribute at index 6: TypedValue{t=0x1d/d=0xff5c5cff a=1 r=0x106002f}
                                                                                                              at
    android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)
                                                                                                              at
    android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6890)
                                                                                                              at
    android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:7071)
                                                                                                              at
    android.widget.FrameLayout$LayoutParams.(FrameLayout.java:446)
                                                                                                              at
    android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:386)
                                                                                                              at
    android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:385)
                                                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:502)
                                                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                                              at
    android.support.v7.view.menu.MenuAdapter.getView(MenuAdapter.java:93) 
                                                                                                              at
    android.support.v7.view.menu.MenuPopup.measureIndividualMenuWidth(MenuPopup.java:160) 
                                                                                                              at
    android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:153) 
                                                                                                              at
    android.support.v7.view.menu.StandardMenuPopup.show(StandardMenuPopup.java:187) 
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.showPopup(MenuPopupHelper.java:290) 
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:175) 
                                                                                                              at
    android.support.v7.view.menu.MenuPopupHelper.show(MenuPopupHelper.java:141) 
                                                                                                              at android.support.v7.widget.PopupMenu.show(PopupMenu.java:233) 
                                                                                                              at
    com.tonightfootball.waiyanhein.adapter.MemeCommentsAdapter$1.onLongClick(MemeCommentsAdapter.java:113) 
                                                                                                              at android.view.View.performLongClick(View.java:5237) 
                                                                                                              at android.view.View$CheckForLongPress.run(View.java:21121) 
                                                                                                              at android.os.Handler.handleCallback(Handler.java:739) 
                                                                                                              at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                                              at android.os.Looper.loop(Looper.java:148) 
                                                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                              at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)</p>
  </blockquote>
  
  <p>I tried this way as well.</p>
  
  <pre><code>viewHolder.container.setOnLongClickListener(new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View view) {
                  PopupMenu popupMenu = new PopupMenu(context,view);
                  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                  @Override
                          public boolean onMenuItemClick(MenuItem item) {
                          return false;
                     }
                  });
                  popupMenu.getMenuInflater().inflate(R.menu.menu_mm_comment_item,popupMenu.getMenu());
  
                  popupMenu.show();
                  return true;
              }
          });
  </code></pre>
  
  <p>I just got the same error. This is my menu xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;item android:id="@+id/m_item_edit_com" android:title="Edit" app:showAsAction="ifRoom|withText" /&gt;
      &lt;item android:id="@+id/m_item_delete_com" android:title="Delete" app:showAsAction="ifRoom|withText" /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>What is wrong with my code?</p>