Fragment nicht wieder aufgenommen, nach der Ausrichtung ändern

Die Fragmente in meine app nicht wieder aufgenommen, um die Aktivität anzuzeigen, wenn das Gerät gedreht wird. Wenn ich verstehe, die Dokumentation (und ähnliche Fragen hier auf SO) richtig ist, sollte dieser behandelt werden, werden die fragment-manager (ohne Angabe android:configChanges in meinem manifest).

Meine Aktivität sieht so aus:

public class MainActivity extends SherlockFragmentActivity {

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

        setContentView(R.layout.activity_main);

        if (savedInstanceState == null){
            getSupportFragmentManager().beginTransaction()
                .add(R.id.main_fragment_placeholder, new DashboardFragment(),"dashboard")
                .commit();
        }
    }
}

Und ein Fragment aussieht (entfällt clicklisteners und so weiter für Klarheit):

public class DashboardFragment extends SherlockFragment {
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
    }
}

Layout-Dateien Aussehen (activity_main.xml):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:id="@+id/main.main">

    <FrameLayout android:id="@+id/main_fragment_placeholder"
             android:layout_height="fill_parent"
             android:layout_weight="1"
             android:layout_width="0px"
             />

</LinearLayout>

Und fragment_layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main.wrapper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <my.layout.DashboardLayout
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:id="@+id/main.dashboard">
    <!-- some buttons here -->
    </my.layout.DashboardLayout>

</LinearLayout>

Allerdings, wenn ich drehen mein Gerät den Bildschirm immer leer wird.

InformationsquelleAutor sgdesmet | 2012-10-25
Schreibe einen Kommentar