Android V7 Support Library Popup Menu

后端 未结 6 754
逝去的感伤
逝去的感伤 2020-12-09 19:06

I\'m trying to implement a PopupMenu with the Support V7 Library. All compiles fine but when I try to call:

    PopupMenu popup = new PopupMenu(this, v);
            


        
相关标签:
6条回答
  • 2020-12-09 19:23

    Your layout file "abc_popup_menu_item_layout.xml" already shows a height defined.

    Either "?attr/dropdownListPreferredItemHeight" is something from a different theme or library (such as ActionBarSherlock), or the error is coming from a different layout file.

    Also, if you swap out "?attr/dropdownListPreferredItemHeight" for something like "60dp" does the error go away?

    0 讨论(0)
  • 2020-12-09 19:28

    You might want to check if you have an appropriate theme specified in your manifest file:

    <application ... android:theme="@style/Theme.AppCompat">
    
    0 讨论(0)
  • 2020-12-09 19:30
    PopupMenu popup = new PopupMenu(this, v);
    

    what's "this" refer to ? the first parameter must be a context like Activity, not ApplicationContext!!

    0 讨论(0)
  • 2020-12-09 19:35

    Add this line to your Activity inside your manifest.xml

    android:theme="@style/Theme.AppCompat"
    
    0 讨论(0)
  • 2020-12-09 19:45

    Also check if there is another style that is applied within each activities in manifest.xml. This will override Theme.AppCompat in application tag.

    0 讨论(0)
  • 2020-12-09 19:46

    @style/Theme.AppCompat.Light resovled the problem for me. @style/Theme.AppCompat is a dark theme, it deosn't fit my applicatoin.

    0 讨论(0)
提交回复
热议问题