Soru & Cevap

navigation drawer'a birden fazla fragment ekleme ...

09.09.2015 - 08:32

merhaba. navigation drawer'a 2 tane fragment eklemeye çalışıyorum. container1 id'li olan layouta fragment1 gelecek, container2 id'li olana da fragment2 gelecek. fragmentleri set ediyorum fakat sadece fragment1 gösteriliyor, diğeri hiç gösterilmiyor. container1'e fragment2 'yi, container2'ye de fragment1'i set edince bu sefer de sadece fragment2 gösteriliyor. drawerLayout'un sadece 2 tane child layout'u olması gerekiyor, benimkinde de drawerLayout 2 tane child layouta sahip, sorun büyük ihtimal bununla alakalı birşeyden kaynaklanıyor ama çözemedim.

layout dosyası :


<android.support.v4.widget.DrawerLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:elevation="7dp">

    <!-- my main content -->
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar
                android:id="@+id/tool_bar"
                style="@style/ToolBarStyle"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways" />

            <LinearLayout
                android:orientation="vertical"
                android:id="@+id/linearLayout"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:background="@color/color_accent_pink">

            </LinearLayout>

        </android.support.design.widget.AppBarLayout>


            <android.support.v7.widget.RecyclerView
                android:id="@+id/newsRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="vertical"
                android:clickable="true"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


    </android.support.design.widget.CoordinatorLayout>

    <!-- my navigation drawer -->
    <RelativeLayout
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="@color/myDrawerBackground">

        <!-- container for fragment1 -->
        <RelativeLayout
            android:id="@+id/container1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/merhabaText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="100dp"
                android:layout_marginRight="40dp"
                android:layout_alignParentRight="true"
                android:text="Hello!"/>

        </RelativeLayout>

        <!-- container for fragment2 -->
        <RelativeLayout
            android:id="@+id/container2"
            android:layout_below="@+id/container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/merhabaText2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="400dp"
                android:layout_marginRight="40dp"
                android:layout_alignParentRight="true"
                android:text="Hi!"/>

        </RelativeLayout>

    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

 

1 Görüntülenme

0 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.