里面有关于Android的操作栏将开关 [英] Put switch inside action bar on Android
本文介绍了里面有关于Android的操作栏将开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的一个项目,目前我正在试图把应用程序的操作栏里面的开关(如Wi-Fi设置:的 http://tinypic.com/r/2l8vt35/6 )
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 )
如何才能做到这一点?
推荐答案
添加安卓actionLayout
您<项目>
在你的菜单XML资源,指向有你的开关的布局XML资源
。然后,使用 getActionView()
在菜单项
来注册监听器在变化开关。
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.
注意开关
仅适用于API级别14或更高。
Note that Switch
only works on API Level 14 and higher.
这篇关于里面有关于Android的操作栏将开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文