2015-02-06 177 views
1

我已經完成了所有其他的答案對這個問題看,但還是沒能解決這個錯誤:DrawerLayout不是滑動抽屜

app:id/drawerLayout) is not a sliding drawer 

我得到closeDrawer行錯誤:

mDrawerLinear = (LinearLayout) findViewById(R.id.drawerLayout); 
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    mDrawerList = (ListView) findViewById(R.id.drawer_list); 

    mDrawerLayout.closeDrawer(mDrawerLinear); 

我設置內容,此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> 

和navigation_drawer XML看起來像這樣

<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> 

我必須缺少一些明顯的東西。有任何想法嗎 ?

回答

3

您對抽屜LinearLayout有錯誤的重力屬性。 android:gravity="left"屬性應該是android:layout_gravity="left"