0

I have my main activity as

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_incipient);
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    TopClipsFragment topClipsFragment = TopClipsFragment.newInstance();
    MyClipsFragment myClipsFragment= MyClipsFragment.newInstance();
    fragmentTransaction.add(R.id.frame_container, myClipsFragment,"My");
    fragmentTransaction.add(R.id.frame_container, topClipsFragment, "Top");
    fragmentTransaction.commit();
}

and a layout file : panel.xml as

<android.support.v4.widget.SlidingPaneLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/voz_action_bar" >
</android.support.v4.widget.SlidingPaneLayout>

So what I am trying to do here is adding two fragments in SlidingPaneLayout in Activity's onCreate method. this thing works fine when I start my application. But when device orientation is changed than I get this exception

E/SlidingPaneLayout(2192): onMeasure: More than two child views are not supported

how can I handle orientation change in this case

Manish
  • 1,946
  • 2
  • 24
  • 36

1 Answers1

0

I think your onCreate method is called when you switch the orientation and you're trying to add more children to the SlidingPaneLayout. Depending on what you want you might block calling the onCreate when you switch the orientation, by adding this in the manifest:

android:configChanges="orientation"

inside the activity block. If you do want the onCreate to be called (maybe you want to change the layout you're using) then you should do it different.

Ciprian
  • 2,879
  • 3
  • 28
  • 28