How to add UI tabs in this new ICS world?

2019-06-08 12:24发布

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:

  1. Kick TabHost into working with ActionBarSherlock. It'll look pig ugly on ICS devices.
  2. 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)
  3. Just use Views as "tabs" to jump between activities

I'm leaning towards the last option, but would appreciate clarification.

1条回答
smile是对你的礼貌
2楼-- · 2019-06-08 12:37

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:

enter image description here

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.

查看更多
登录 后发表回答