android-navigationview

Change specific icon's color in NavigationDrawer

▼魔方 西西 提交于 2019-12-12 03:16:43
问题 I have a problem with changing the icon's color in default Drawer Menu in Android, there are lots of topics but they only explain changing the tint color of whole menu not a specific icon: For example I want to change the color of Favorites icon to yellow 回答1: You can change icon of the menu from here like this from activity_drawer_drawer.xml layout <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single

Inflating a custom view below header view in Navigation view android

主宰稳场 提交于 2019-12-11 14:25:44
问题 I have a DrawerLayout with NavigationView as shown below <?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" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:openDrawer="start"> <include layout="@layout/app_bar_dynamic_screen" android:layout_width=

Null Pointer Exception on Navigation Header Initialized Variables [duplicate]

北慕城南 提交于 2019-12-11 10:56:20
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . Why am i getting Null Pointer Exceptions on my NavigationView header initialized variables while setting the values from shared preferences? Here is my code private void setNavigationHeader() { View navHeader = mNavigationView.getHeaderView(0); TextView mProfileName = (TextView) navHeader.findViewById(R.id.profile_name); TextView mProfileEmail = (TextView) navHeader

remove line divider from NavigationView android

情到浓时终转凉″ 提交于 2019-12-11 00:20:09
问题 i have this menu for the NavigationView of layout: <item android:title="title1"> <menu> <item android:id="@+id/nav_tab1" android:icon="@drawable/ic_action_nav_tab1" android:title="test1" /> <item android:id="@+id/nav_tab2" android:icon="@drawable/ic_action_nav_tab2" android:title="test2" /> </menu> </item> <item android:title="title2"> <menu> <item android:id="@+id/nav_settings" android:icon="@drawable/ic_action_settings" android:title="test3" /> </menu> </item> how can remove the line

What's the purpose of tools:openDrawer=“start” when creating a DrawerLayout (with NavigationView) from the wizard?

社会主义新天地 提交于 2019-12-10 00:58:47
问题 Creating an activity with navigation drawer in Android Studio causes this to be shown in the XML code: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> If I remove the tools:openDrawer

How to add draggable icon with navigation drawer

强颜欢笑 提交于 2019-12-09 12:24:26
问题 My problem: I want to add draggable icon in navigation drawer. This icon combined with listview of navigation drawer when drawer open. see similar like this, What I have tried, I searched in StackOverflow like similar question this, Draggable drawer with a handle (instead of action bar) on top of other apps But all answer suggest to 3rd party library. My question 1.It`s possible to add draggable icon with navigation drawer? 回答1: For drag layout there is github library which is useful for it

How to add a collapsible menu item inside navigation drawer in android?

可紊 提交于 2019-12-09 09:44:44
问题 I have a DrawerLayout enclosing a NavigationView and this layout activity serves as a common Navigation drawer for all the activities in my app. I am providing the menu resource for app:menu in navigation view. I have some menu items, but I want one menu item to be collapsible/expandable, so that when I click on it, it expands to show two submenus and collapses again on a second click. I have added submenus by adding another <menu> inside the <item> but cant make it collapsible/expandable.

onNavigationItemSelected not working in NavigationView

落爺英雄遲暮 提交于 2019-12-08 09:18:32
Please can someone help me with fragments from the navigation drawer, for some reason I can't get them to work and all the code looks right. Here is the link to the source code. Have a look at your MainActivity.java . You have implemented the callbacks for NavigationView.OnNavigationItemSelectedListener in MainActivity as below, @Override public boolean onNavigationItemSelected(MenuItem menuItem) { // blah blah } Also check the setupDrawerContent method. private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener( new NavigationView

NavigationView theme selected item background style

北城以北 提交于 2019-12-07 21:55:20
问题 I have created an alternative theme for my app which is Dark. I use a navigation bar which is defined as <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> It has two groups defined within the menu which are selectable <item android:id="@+id/sort_item"

Where to findViewById in a Drawer MainActivity?

最后都变了- 提交于 2019-12-07 13:13:16
问题 I'm using the Android Studio template for the Drawer Navigation. I wanted to add a click event to the drawer's header, but when I try to findViewById in the onCreate() method, I get a null exception. I'm guessing it's because it hasn't been inflated yet. Interesting to me is that findViewById on the drawer_layout and the nav_view returned an object. I tried to do this: drawer.findViewById; and this: navigationView.findViewById; But that still gives me an exception. So my question is two fold: