Put switch inside action bar on Android

前端 未结 1 1938
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 01:54

I\'m working on a project where I am currently trying to put a switch inside the applications action bar (as in the wi-fi settings : http://tinypic.com/r/2l8vt35/6 )

How

相关标签:
1条回答
  • 2021-02-02 02:15

    Add android:actionLayout to your <item> in your menu XML resource, pointing to a layout XML resource that has your Switch. Then, use getActionView() on the MenuItem to register listeners on changes in the switch.

    Note that Switch only works on API Level 14 and higher.

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