简体   繁体   English

我可以在ActionBarSherlock中使用Switch Widget吗

[英]Can I use Switch Widget with ActionBarSherlock

My application uses actionbarsherlock. 我的应用程序使用actionbarsherlock。 My question is can I use Switch Widget, along with actionbarsherlock (switch widget appearing as part of actionbarsherlock)? 我的问题是我可以同时使用Switch Widget和actionbarsherlock(switch小部件作为actionbarsherlock的一部分出现)吗? Is it supported? 支持吗?

I have read questions regarding actionbarsherlock and switch widget, but none of them really answered my question. 我已经阅读了有关actionbarsherlock和switch小部件的问题,但是没有一个问题能真正回答我的问题。

If the answer is Yes, can someone point me to an example? 如果答案是肯定的,有人可以给我指出一个例子吗?

No this is not possible. 不行,这是不可能的。 The switch widget is not part of the ActionBar and therefore not part of ActionBarSherlock. 开关小部件不是ActionBar的一部分,因此也不是ActionBarSherlock的一部分。

You can only use it if you target API Level 14 or up or if you recreate it from the Android source code yourself. 仅当您定位到API级别14或更高版本,或者您自己从Android源代码重新创建它时,才可以使用它。

You can use setCustomView() method to insert whatever layout you want in the Android ActionBar and therefor also with ActionBarSherlock that has exactly the same API. 您可以使用setCustomView()方法在Android ActionBar中插入所需的任何布局,因此也可以使用具有完全相同API的ActionBarSherlock

So you can just add a layout with a Switch in it. 因此,您只需添加一个带有Switch的布局即可。

To use it in API < 14 I've personally gone through the process of importing the Switch open-source code into my project and it's not that paintfull. 要在<14的API中使用它,我个人已经完成了将Switch开源代码导入我的项目的过程,而且还不是很完整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM