Fragment ersetzt, die immer noch sichtbaren hintergrund

Ich versuche, ersetzen Sie ein fragment durch ein anderes mit neuen navigation drawer pattern. Es scheint zu funktionieren, aber wenn ich wählen Sie eine andere option aus der Schublade das neue fragment wird geladen, aber beide Fragmente sichtbar sind. Ich bin nicht mit statischen fragment-layout, also ich weiß nicht wo das problem ist.

Fragmente geladen sind, durch onItemClick Methode der Umsetzung AdapterView.OnItemClickListener auf meine Tätigkeit.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Fragment fragmentToShow = null;
    //Load desired fragment
    switch (position) {
        case 0: //Authors
            if (fragmentAuthors == null) fragmentAuthors = new FragmentAuthors();
            fragmentToShow = fragmentAuthors;
            break;
        case 1: //Books
            if (fragmentBooks == null) fragmentBooks = new FragmentBooks();
            fragmentToShow = fragmentBooks;
            break;
    }
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(R.id.ActivityMain_Drawer_FrameMain, fragmentToShow);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
    mDrawerLayout.closeDrawers();
}

Layout

<!-- The main content view -->
<FrameLayout
    android:id="@+id/ActivityMain_Drawer_FrameMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light" />

<!-- The navigation drawer -->
<FrameLayout
    android:id="@+id/ActivityMain_Drawer_FrameMenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@android:color/background_light">
    <ListView
        android:id="@+id/ActivityMain_Drawer_FrameMenu_List"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />
</FrameLayout>

Screenshots

https://dl.dropboxusercontent.com/u/1763308/Screenshots/device-2013-05-27-113128.png
https://dl.dropboxusercontent.com/u/1763308/Screenshots/device-2013-05-27-113139.png

InformationsquelleAutor Zetch | 2013-05-27
Schreibe einen Kommentar