2017-11-30 27 views
0

ナビゲーション用引き出しがあります。私は1つのヘッダーと他のアイテムリストがあります。 今の問題は、同じ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

NavigationView

2.Addレイアウト1.Use

+1

これはコメントでもよいし、関連するコードを投稿することもできます。リンクは将来満了する可能性があります。 –

+0

すでに回答が複写されていますが、これまでに回答したのと同じリンクが含まれています。 –

0

は、レイアウトにRecyclerViewを3.add(とGridLayoutManagerを設定)

重要なのは、あなたのコード内のinflateHeaderViewメソッドを使用しています。

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

ヘッダーにアイテムを追加するだけで、それを消してしまいました.1つのアイテムをクリックしてから、ヘッダーアイテムに値を設定して、それを表示するように設定します。 – KeLiuyue

関連する問題