Search code examples
androidpanes

Android PanesLibrary Background of the activity container


I'm a new user of PanesLibrary but I'don't know how to show a personal layout on the background when the app starts. The code is like the example on the github without auto generated fragmentes and Example Fragment:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setPaneSizer(new ExamplePaneSizer()); //inner class like on the github example

    // Lets setup a menu and a first pane!
    if (savedInstanceState == null) {
        Fragment menu = new CatFragment(); //show list of categories
        setMenuFragment(menu);
    }
}

And this is the layout of ExampleActivity:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SandboxActivity" >

<com.mapsaurus.paneslayout.PanesLayout
    android:id="@+id/panes"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" 
    >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Some Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</com.mapsaurus.paneslayout.PanesLayout>

The proble is that the TextView is not showed. Thanks!


Solution

  • I resolved. Simply add a new Fragment

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setPaneSizer(new ExamplePaneSizer());
        // Lets setup a menu and a first pane!
        if (savedInstanceState == null) {
            Fragment menu = new CatFragment();
            Fragment instr = new InstructionFragment();
            setMenuFragment(menu);
    
            addFragment(menu, instr);