2017-11-30 32 views
0

내비게이션 서랍이 있습니다. 하나의 헤더와 다른 항목 목록이 있습니다. 이제 문제는 같은 row.Like탐색 서랍에서 같은 행에 3 개의 항목을 추가하는 방법은 무엇입니까?

Header xyz 

    -------------------------- 
     Image Text  Text -----> row one 
    ----------------------------- 
     iamge text  text ------> row two 
    ---------------------------- 
     image text  text ------> row three 
    --------------------------- 
----- ....... so on 

그리고 경우에 세 가지 항목을 추가하는 방법입니다 항목 헤더에 표시해야하는 목록의 모든 항목에 사용자가 클릭이. 나를 안내 해줘.

+0

의 중복 가능성 https://stackoverflow.com/questions/21796209/how-to-create-a-custom-navigation -drawer-in-android –

답변

0

사용자 지정 탐색 창을 만들어야 사용자 요구 사항을 충족시킬 수 있습니다. 이 튜토리얼에 대한 자세한 내용은 http://www.tutecentral.com/android-custom-navigation-drawer/

이 정보가 도움이 될 수 있습니다. NavigationView

2.Add 레이아웃

NavigationView에 1. 한

+1

이것은 주석이거나 관련 코드를 게시 할 수 있습니다. 링크가 앞으로 만료 될 수 있습니다. –

+0

이미 중복 답변으로 제공되는 답변에는 지금까지 답변 한 동일한 링크가 포함되어 있습니다. –

0

는 중요한 코드에서 inflateHeaderView에게 방법을 사용하는 것입니다

레이아웃 RecyclerView을 3.add (그리고 GridLayoutManager 설정).

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white" 
    android:fitsSystemWindows="true"> 

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

</FrameLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_width="@dimen/dp_200" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@color/white" 
    android:paddingTop="@dimen/dp_25"/> 
</android.support.v4.widget.DrawerLayout> 

header_layout

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      android:orientation="vertical"> 

<TextView 
    android:id="@+id/tv_header" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
</android.support.v7.widget.RecyclerView> 

</LinearLayout> 

활동

View headview = mNavigationView.inflateHeaderView(R.layout.header_layout); 
TextView tvHeader = (TextView) headview.findViewById(R.id.tv_header); 
RecyclerView recyclerView = (RecyclerView) headview.findViewById(R.id.recycler_view); 
recyclerView.setLayoutManager(new GridLayoutManager(this,3)); 
recyclerView.setAdapter(mAdapter); 
+0

답변 해 주셔서 감사합니다. 제 질문을 수정했는지 확인해주십시오. 미리 감사드립니다. –

+0

머리글에 항목을 추가하기 만하면됩니다. 그런 다음 한 항목을 클릭 한 다음 값을 머리글 항목으로 설정하고 표시되도록 설정합니다. – KeLiuyue