java - Why badge doesn't appear? -


i try make smth this:

введите сюда описание изображения

to obtain result use code:

i have navigationview

<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_second"     app:menu="@menu/activity_third_drawer" /> 

i have menu xml file:

<?xml version="1.0" encoding="utf-8"?> 

<group android:checkablebehavior="single">      <item         android:id="@+id/nav_inbox"         android:icon="@drawable/ic_mail_outline_white"         android:title="inbox"         app:actionlayout="@layout/badge" /> </group>  <item android:title="@string/about_app">     <menu>         <item             android:id="@+id/nav_about"             android:icon="@drawable/ic_close_24dp"             android:title="@string/about1" />     </menu> </item> </menu> 

and have badge xml file:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">  <textview     android:id="@+id/textmenuitemcount"     android:layout_width="wrap_content"     android:text="rrrr"     android:layout_height="wrap_content"     android:layout_alignparentend="true"     android:textcolor="@android:color/holo_blue_light"     android:textstyle="bold"     android:textsize="16sp"     android:alpha="0.6"/> </relativelayout> 

then try set 2 badge in mainactivity:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_mainsecond);      navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view);     menuitem item = navigationview.getmenu().finditem(r.id.nav_inbox);     menuitemcompat.setactionview(item, r.layout.badge);     relativelayout notifcount = (relativelayout) menuitemcompat.getactionview(item);     textview tv = (textview) notifcount.findviewbyid(r.id.textmenuitemcount);     tv.settext("2"); } 

and nothing.

enter image description here

i have tried debug , show me ok.

enter image description here

please me. doing wrong?

easiest option provide fragment custom layout second child drawerlayout instead of navigationview. , work navigationview instead can give lot more customizations.

follow slidenerd tutorial approach. watch videos total understanding :) :

https://www.youtube.com/watch?v=zwpeh9k8i7q

if still want stick using navigationview, check out duplicate question have asked. gives approach.

how create custom navigation drawer in android


Comments

Popular posts from this blog

Angularjs unit testing - ng-disabled not working when adding text to textarea -

sql - invalid in the select list because it is not contained in either an aggregate function -

How to start daemon on android by adb -