简体   繁体   中英

Can I use Switch Widget with ActionBarSherlock

My application uses actionbarsherlock. My question is can I use Switch Widget, along with actionbarsherlock (switch widget appearing as part of actionbarsherlock)? Is it supported?

I have read questions regarding actionbarsherlock and switch widget, but none of them really answered my question.

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.

You can only use it if you target API Level 14 or up or if you recreate it from the Android source code yourself.

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.

So you can just add a layout with a Switch in it.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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