0

I need to develop fragments layouts for both portrait and landscape. In landscape mode, both fragments should be displayed and in portrait mode, only first fragment should be displayed and when the user swaps the screen, then the second fragment is displayed. Similar to these screens. But I don't have any ListView as the given tutorial. I am using Android.app Fragments so I cannot use OnItemSelectedListener to swap to the second fragment when in the portrait screen.

I know there is no ViewPager in android.app. So I'm confused and my question is, do I have to use both android.support.v4.app library (to swap fragments)and Android.app Fragments(to display both fragments in landscape mode) in this scenario or else is there any other way to accomplish this?

NOTE: I have read this question but I could not get an answer for my problem.

collinx
  • 39
  • 1
  • 9
Zusee Weekin
  • 1,348
  • 2
  • 18
  • 41

1 Answers1

2

You might have confused I guess. The android.support.v4.app is an support library to use the ViewPager from Android version GingerBread and above, whereas the other one is to support from HoneyComb and above (see the Android version release hierarchy table). It is enough to use anyone, as per your requirement. If you want to support the older devices then go for v4 or else the normal one is enough.

And basically the ViewPager will swipe either direction. Even if you don't have a listview, you can swipe right to the next screen.

Check this simple ViewPager tutorial

Update:

As you don't need swiping in the Landscape mode better to go with the android.support.v4.app with static fragments where you'll get the backward compatibility as well for the older devices

Piyush
  • 18,895
  • 5
  • 32
  • 63
Akbarsha
  • 2,422
  • 23
  • 34
  • Thank you for the support Sha. I know to use ViewPager using android.support.v4.app. But my problem is I have to arrange fragment in landscape mode. Do have any idea to do it using android.support.v4.app or to make fragments swap using android.app? Or else I want to know do I have to use both. – Zusee Weekin Mar 28 '14 at 05:59
  • Better go with v4 and in the landscape mode use the static fragments. In landscape mode you don't want any swipings rite? @ZuseeWeekin – Akbarsha Mar 28 '14 at 06:20
  • you can mark this as answer if it suits you. so that I'll get encouraged@ZuseeWeekin – Akbarsha Mar 28 '14 at 09:26
  • I already up vote your answer. But still I'm not clear how to implement portrait view with two fragments using android.support.v4.app.If it is possible could you please direct me to such a example or tutorial? – Zusee Weekin Mar 31 '14 at 02:47
  • pls go check this video tutorial this would help you a lot http://bit.ly/1hS9hQl @ZuseeWeekin – Akbarsha Mar 31 '14 at 05:03