Context menu for blank space in a listview

前端 未结 1 832
执笔经年
执笔经年 2021-01-29 03:30

I have a simple LinearLayout with ListView inside it (match_parent both for width and height). I need a context menu to show up upon a long touch on ANY place in th

相关标签:
1条回答
  • 2021-01-29 03:57

    I don't think that long clicking anywhere on the ListView to get a ContextMenu it's a normal behavior, one the user will expect(especially in your case, with the user clicking the empty space below the ListView and a ListView ContextMenu would appear).

    Anyway, for your example, you can set your ListView height attribute to wrap_content(If I remember right, this is the recommended value) and then register the Contextmenu for the ListView and the parent LinearLayout(of course you'll have to provide the same code for both).

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