Ich bin mit dieser Bibliothek: https://github.com/mikepenz/MaterialDrawer Ich habe einen NavigationDrawer auf der linken Seite mit Navigationselementen und auf der rechten Seite habe ich eine zusätzliche Schublade:NavigationDrawer mit benutzerdefinierten Fragment innerhalb?
new DrawerBuilder()
.withActivity(this)
.withDrawerGravity(Gravity.END)
.append(result);
Ich habe auch ein Fragment mit einem RecyclerView und einige weitere Ansicht innen:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/listBackground">
<android.support.v7.widget.RecyclerView
android:id="@+id/contactsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:listitem="@layout/fragment_contacts_item" />
<LinearLayout
android:id="@+id/layoutNoContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:paddingBottom="128dp"
android:visibility="gone">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/sad" />
</LinearLayout>
aufbläst Dieses Fragment, das Layout und fügt Einträge in die RecyclerView.
Das ist mein Haupt Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@color/listBackground">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
android:clickable="true" />
</RelativeLayout>
Wie kann ich diesen Brauch Fragment zeigen, die jederzeit meine Kontakte in der NavigationDrawer zeigt anstelle von Navigationselementen?
Vielen Dank für Ihre Hilfe! Ich habe meine Hauptlayoutdatei hinzugefügt, wo müsste ich sie hinzufügen? Und wie würde ich den Inhalt dort hineinlegen? Nur mit einer normalen FragmentTransaction? – user754730
Das Fragment wird statisch basierend auf dem Attribut "android: name" hinzugefügt. – EpicPandaForce
Dieses Layout sollte in der Aktivität (Aktivitätsinhaltslayout) verwendet werden, in der Ihre Schublade präsentiert werden soll. Wenn Sie ein Fragment dynamisch hinzufügen möchten, sollten Sie den Inhalt des Tags durch ersetzen und Fragment mit normaler FragmentTransaction zu diesem Frame-Layout hinzufügen. Weitere Informationen finden Sie in der Dokumentation zu Fragmenten: https://developer.android.com/guide/components/fragments.html –