Alternative of TabAcitivity

半城伤御伤魂 提交于 2019-12-10 21:03:30

问题


Hi Friends i want to create tab's in project. For making tab there is two way which i found

1) Extends the activity class with TabActivity class which is deprecated as i seem this is a easy way but don't why it is deprecated so i want to know whether any other class or any alternative for that class.

2) Create individual activity for every tab which lengthy but convenient way but still feels TabActivity is fast one.

I was wondering if anybody could tell me, Thanks


回答1:


For making tab there is two way which i found

You can also:

  • Use a ViewPager with a tabbed indicator, such as PagerTabStrip, the TabPagerIndicator from the ViewPagerIndicator project, PagerSlidingTabStrip, etc.

  • Use tabs in the action bar (note: these will convert into a drop-down list in some device sizes and orientations)

  • Use FragmentTabHost

  • Use TabHost and TabWidget in a regular Activity

The following sample projects demonstrate:

  • PagerTabStrip: https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/TabPager

  • TabPageIndicator: https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/VPI

  • action bar tabs: https://github.com/commonsguy/cw-omnibus/tree/master/ActionBar/TabFragmentDemo

  • TabHost and TabWidget: https://github.com/commonsguy/cw-omnibus/tree/master/WidgetCatalog/Tab

Note that the first three samples all use ActionBarSherlock, so they run on Android 2.x devices. The fourth one should run on anything from Android 1.0 onwards.




回答2:


use Fragments as an alternative of TabActivity . To get a feel like Tabs you can do this. Use a FragmentActivity. Add different Fragments in it. And use ViewPager to switch between different fragments.



来源:https://stackoverflow.com/questions/17379725/alternative-of-tabacitivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!