简体   繁体   中英

Tabbed activity in Android

I am wondering what is the recommended way for achieving a tab fragment activity (supporting swipes) like the picture below. I mean, what class should I extend and for the Listener, what kind of listener do I need to implement?

I am following a tutorial what uses ActionBarActivity and ActionBar.TabListener, which have been deprecated and now I am looking for a way to replace them with something else.

在此处输入图片说明

It seems that you have not understood its working completely. You should first know the difference between the Scroll tabs vs fixed tabs , if you have more then 3 tabs then You should use scroll able swipe tabs. But there are general procedure for these. 1. Make Fragments (So that you can change views when clicked on the tabs) 2. Create View Pager (if you are using fragments then you have two options a)FragmentStatePagerAdapter b)FragmentPagerAdapter ) 3. Add titles inside pager Now there you go you can use this adapter to change the views from left to right or right to left and as when the views get change you can change the selected tab and inversely when specific tab is selected you can navigate to specific view also.

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