Reputation: 1191
I have looked through all other answers to this question, but still couldn't solve this error:
app:id/drawerLayout) is not a sliding drawer
I get error on closeDrawer line:
mDrawerLinear = (LinearLayout) findViewById(R.id.drawerLayout);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.drawer_list);
mDrawerLayout.closeDrawer(mDrawerLinear);
I am setting content this xml>
<RelativeLayout 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.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<include layout="@layout/mainv2"/>
<!-- The navigation drawer -->
<include layout="@layout/navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
and navigation_drawer xml looks like this
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:layout_width="240dp"
android:layout_height="match_parent"
android:background="@android:color/black"
android:gravity="left"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/fbName"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:text="Please login."
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white"
android:textSize="12dp" />
</LinearLayout>
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</LinearLayout>
I must be missing something obvious. Any ideas ?
Upvotes: 2
Views: 1032
Reputation: 39191
You've the wrong gravity attribute for the drawer LinearLayout. The android:gravity="left"
attribute should be android:layout_gravity="left"
.
Upvotes: 4