I'm currently creating and defining a navigation drawer. I want now a header view, like their on the google apps, above the item rows. I only found examples with RecyclerViews, and i dont want to use it. I have all finished with a ListView and all other stuff. Maybe someone can help me :) Thanks in advance
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
You can create
NavigationView
using android design support library without having pain to create listview or RecyclerView, its all created by android.To add it to your project you need to add the android design support library to your project, add below line in build.gradle
Check out android design support features here
First create a header(header.xml)
Next create a menu resource file, the items in the menu will be the items displayed in the drawer(drawer.xml)
Next create a
DrawerLayout
file, within the drawerlayout you can see I have included aToolbar
and a 'FrameLayout`. When the item in the drawerlayout is clicked you can replace fragment.Also within it is the NavigationView with these parameters:
app:headerLayout
is the header.xml that we created in step 1.app:menu
is the menu resource item i.e drawer.xmlNext in your MainActivity extend AppcompatActivity,
Intialise NavigationView and call setNavigationItemSelectedListener to get click events,
Step by step procedure to create navigationview go here
How it would look: