Recently, I encountered a problem in a small project, that is, using TabWidget and ViewPager to create a Tab That Can Be slide. The effect can still be displayed on Android2.3, but the TabWeight style will be changed to the holo style on the 4.0 system. If text and icons are added to Tabweight. In the 4.0 system, only text is displayed by default (an icon is displayed when the text is empty ).
I cannot accept the two display effects of the same application.
Then I searched the internet.
Find a solution: http://stackoverflow.com/questions/10745092/icon-in-tab-is-not-showing-up
However, I think custom TabWeight will make a simple problem more complicated.
The original intention is to create a TAB interface that can be slide, so that tabhost, ViewPager, and custom TabWeight are used, and the structure is too cumbersome. It is better to simplify the problem.
Determine the style as holo. To be compatible with versions earlier than 4.0, use the ActionBarSherlock package
ActionBarSherlock can go to the http://actionbarsherlock.com/download.html under the website
You can also go to GIT to find the https://github.com/JakeWharton/ActionBarSherlock
Using the tab in ActionBarSherlock, the holo style is relatively simple, so no icon or anything is added to the flexibility.
I don't need to post my own code. I found an example on the Internet and pasted the key code. If you are interested, I 'd like to go to the original post and check it in detail.
MyFragmentPagerAdapter PAGE_COUNT = 2 Fragment getItem(= 0= "current_page", arg0+1 1= "current_page", arg0+1
The code of the main MainActivity, and then the FragmentActivity in it can be added with either of them.
MainActivity ==== onPageSelected(= = ="Android"="Apple"
Example of the link http://wptrafficanalyzer.in/blog/implement-swiping-between-tabs-with-viewpager-in-action-bar-using-sherlock-library/ interested in students to see it