Add toggle button to the menu to stop and start service

后端 未结 6 837
抹茶落季
抹茶落季 2020-12-11 03:24

I am trying to enable the user to stops and starts service which I am implementing from the Menu where the text is will be changed when he clicks it so I want to add T

6条回答
  •  孤街浪徒
    2020-12-11 04:06

    Menu resources are distinct from conventional layouts; you cannot simply add widgets into them and expect them to work. The only elements allowed inside a menu resource is or .

    Using a custom layout inside a menu isn't possible, I'm afraid. You may instead want to replace the entire menu with a PopupWindow, and supply your layouts there instead.

    You may want to consider two alternatives:

    • Using a conventional menu entry as a toggle, or
    • Placing the ToggleButton immediately inside the Actionbar/Toolbar, instead of inside the menu.

提交回复
热议问题