问题
I've a requirement to show tabs in an app. I've actually never used TabHost etc before, and the docs suggest the whole thing is a mess. TabActivity has been deprecated. I can't easily use it anyway as I'm using ActionBarSherlock so I cannot inherit from it. Then of course as of ICS, I'd not use a TabHost anyway, I'd use tabs on the Action Bar. As my tabs are just text and are simple in nature I see three options:
- Kick TabHost into working with ActionBarSherlock. It'll look pig ugly on ICS devices.
- Use ActionBarSherlock and implement tabs, on the assumption it renders the ActionBar tabs in some way on versions of Android prior to v4 (I have no idea if it does, I suspect not)
- Just use Views as "tabs" to jump between activities
I'm leaning towards the last option, but would appreciate clarification.
回答1:
Use ActionBarSherlock and implement tabs, on the assumption it renders the ActionBar tabs in some way on versions of Android prior to v4 (I have no idea if it does, I suspect not)
It would appear that ActionBarSherlock supports tabs on all Android API levels that ActionBarSherlock itself supports.
For example, they demo it on an Android 2.3 environment:
And the FAQ talks about tab support "on pre-3.0 devices".
And the theming page lists theme attributes for styling tabs.
And the Google Group has all sorts of discussion on using tabs.
来源:https://stackoverflow.com/questions/8563351/how-to-add-ui-tabs-in-this-new-ics-world