2013-10-02 6 views
2

Android 탐색에 listView 대신 Fragment가 포함될 수 있나요? navigationDrawer 내부에 하위 액티비티를 표시하고 싶습니다. 안드로이드 데모 :Android 탐색 서랍 콘텐츠

Creating a Navigation Drawer

만 목록보기를 보여주고 난 오직리스트 뷰와 함께 사용했습니다.

+1

당신은 FrameLayouts –

답변

2

usual way에 XML을 통해 조각을 추가 할 수 있습니다.

그래서, 링크 된 예를 보면, 당신은 스왑 아웃 것이다 :

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    ... > 
    <!-- The main content view --> 
    <FrameLayout 
     ... /> 
    <!-- The navigation drawer --> 
    <ListView android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     android:background="#111"/> 
</android.support.v4.widget.DrawerLayout> 

의 경우 :

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    ... > 
    <!-- The main content view --> 
    <FrameLayout 
     ... /> 
    <!-- The navigation drawer --> 
    <fragment android:name="com.example.MyNavigationDrawerFragment" 
     android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     ... /> 
</android.support.v4.widget.DrawerLayout> 
+0

을 포함하여 서랍으로 어떤 뷰 그룹 /보기를 할 수 있습니다 나는 내가 너무 의심 프레임 워크에서 허용했는지 확인하고 싶다면 – j2emanue

+1

조각에 'android : clickable = "true"'를 설정해야합니다. 그렇지 않으면 클릭 이벤트가 주 프래그먼트로 전달됩니다. –