1

I have a Problem with my application. After i done this: Android 5.0 material design style navigation drawer for KitKat

My app does not Start. After Start, the screen goes black. If I remove the fragment-tag from layout file, it works. I have the same structure like in the tutorial. I tested on emulator and on an Galaxy S2.

Here some code: layout/activity_main.xml

<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </RelativeLayout>

</LinearLayout>

<fragment
    android:id="@+id/left_drawer"
    android:name="example.fragments.NavigationDrawerFragment"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    tools:layout="@layout/fragment_navigation_drawer"
    />

MainActivity:

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_main);

    this.mNavigationDrawerFragment = (NavigationDrawerFragment) this.getSupportFragmentManager().findFragmentById(R.id.left_drawer);
    if (this.mNavigationDrawerFragment == null) {
        this.mNavigationDrawerFragment = new NavigationDrawerFragment();
    }

    // Set up the drawer.
    this.mNavigationDrawerFragment.setUp(R.id.left_drawer, (DrawerLayout) this.findViewById(R.id.drawer_layout));

}

If I remove:

<fragment
    android:id="@+id/left_drawer"
    android:name="example.fragments.NavigationDrawerFragment"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    tools:layout="@layout/fragment_navigation_drawer"
    />

Then it works :-/

Community
  • 1
  • 1
lars.a
  • 71
  • 7
  • Which version is your S2 on. It might not understand the value "start". That's why @jpardogo used `left|start` in his code! – Wolfram Rittmeyer Dec 23 '14 at 14:17
  • Please amend the G+ thread with the reason about what went wrong. You could/should link to the comment (the timestamp is linked with a link you can use for that). Don't leave one thread out there dangling without solution :-) – Wolfram Rittmeyer Dec 23 '14 at 20:34

0 Answers0