0

I have

Portrait Mode: - Containing View Pager with 2 Tabs (which contains 2 Fragments both having different views and inflating 2 different layouts.

Landscape Mode: - Containing View Pager with 3 Tabs (which contains 3 Fragments all having different views and inflating 3 different layouts.

How can I achieve this ?

Thanks,

Ahmad Ali Nasir
  • 1,382
  • 3
  • 16
  • 29

1 Answers1

1

Create a boolean in values-land that is set to true and false in values.

<resources>
    <bool name="is_landscape">false</bool>
</resources>

Depending on the value of this boolean, you can set different Fragments in your adapter.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • This doesn't work completely, I have just tried it. The problem is the app crashes as the values-land variable are only accessible if the app is in landscape mode.. Code: if(getResources().getBoolean(R.bool.is_landscape)){ //code }else { //code } Log: android.content.res.Resources$NotFoundException: Resource ID #0x7f070006 at android.content.res.Resources.getValue(Resources.java:1014) at android.content.res.Resources.getBoolean(Resources.java:796) – Ahmad Ali Nasir May 26 '13 at 14:53