android-navigationview

App crashes when accessing multiple textviews from navigation header

牧云@^-^@ 提交于 2019-12-25 18:44:23
问题 recently i tried an app with navigation view with header . the header contains 2 textview, a name and email . When i tried to setText the textview dynamically through code,it throws null pointerexception. Can anyone please help me to resolve this problem. Navigation_view <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

Replace Navigation View Item Ripple Effect

佐手、 提交于 2019-12-25 01:46:37
问题 I am attempting to replace what I thought was the default item background of the NavigationView . So I created a drawable to replace the background and applied it using the itemBackground attribute. background_navigation_view_item.xml <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/navigation_item_background_tint"> <item android:id="@android:id/mask" android:top="4dp" android:bottom="4dp" android:left="8dp" android:right="8dp"> <shape android:shape=

Android: Navigation Component not working with both: <navigation> and NavigationItemSelectedListener

安稳与你 提交于 2019-12-24 06:34:55
问题 What I have done: I have created Navigation Drawer Activity , As updated new format of Navigation Drawer Activity , As per new Android architecture I got it with Navigation Component structure. The NavigationView code with NavController and NavigationUI as below which is opening fragment when I click on any navigation item. DrawerLayout drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); // Passing each menu ID as a set of Ids because each /

Ripple effect on NavigationView item

…衆ロ難τιáo~ 提交于 2019-12-23 17:02:05
问题 I have NavigationView in my DrawerLayout and let's say it has simple menu <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/nav_settings" android:icon="@drawable/ic_settings_black_24dp" android:title="@string/title_settings"/> </menu> Now I set listener for click: mNavigationVeiw.setOnNavigationItemSelected(this); @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.nav_settings:

Error inflating class com.google.android.material.navigation.NavigationView after migration to AndroidX

我是研究僧i 提交于 2019-12-22 08:06:09
问题 After I updated my project to AndroidX with targetSdkVersion set to 28, my project crashes on installing it from the store for beta testing. The following is the error log I receive: 2019-07-08 08:28:33.026 32011-32011/? E/AndroidRuntime: FATAL EXCEPTION: main Process: hu.itq.oakprotection, PID: 32011 java.lang.RuntimeException: Unable to start activity ComponentInfo{hu.itq.oakprotection/hu.itq.oakprotection.MainActivity}: android.view.InflateException: Binary XML file line #15: Binary XML

NavigationView(Change Color of Selected Item)

蹲街弑〆低调 提交于 2019-12-18 03:32:33
问题 Is there any way to change the Item color programmatically of the selected item in the navigation drawer? I'am able to use the app:itemTextColor, but the problem is if i used this, the checked in the menu item will not highlight. <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_home" android:icon="@drawable/ic_home_black_24dp" android:title="Home" /> <item android:id="

Default Navigation Drawer View to ExpandableListView

耗尽温柔 提交于 2019-12-17 10:55:12
问题 In Android Studio 2.1.2, if i create a default navigation activity I get this view: Which uses the following activity_main.xml file: <?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" android

How I can remove the unnecessary top padding of the Navigation view?

浪尽此生 提交于 2019-12-17 06:08:25
问题 There's an unnecessary top padding between the header and the first item shown in this picture. How it can be removed? you can find the source code here: https://github.com/chrisbanes/cheesesquare 回答1: NavigationView seeks to match the material design specs for the navigation drawer which state an 8dp space between content areas. Generally there are no ways to override NavigationView to specifically break the specifications. 回答2: You can override predefined dimensions at your dimens.xml as;

Navigation View's selectors behave incorrectly

社会主义新天地 提交于 2019-12-14 02:19:22
问题 I'm following this color scheme of Navigation View. I created 3 selectors, for background, text and icon. When I set the selectors, my navigation view looked like this: The problem is that no item is shown selected and if I press one item, all items' background color changes to gray. Icon never gets the primary color. Here is are the XMLs: <android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start"

How to programmaticallly remove submenu from navigation drawer in Android?

左心房为你撑大大i 提交于 2019-12-13 16:14:00
问题 I am developing an Android app. Firstly, let me tell you that I am not professional. What I am doing now is I am adding submenu to menu depending on a condition. But I need to do it very often in my app. But my problem is I added a submenu to the menu as first time. But second time when I update menu depending on condition, existing submenu is not removed and new submenu is appended to navigation drawer. How can I remove submenu that is programmatically added to menu? Why my code is not