由网友(逐风剑客)分享简介:我工作的一个项目,目前我正在试图把应用程序的操作栏里面的开关(如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 appli...
我工作的一个项目,目前我正在试图把应用程序的操作栏里面的开关(如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.
相关推荐
最新文章