Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the menu actionLayout value?

I have a navigation drawer and I can change font, color etc.. by accessing the navigationView.getHeaderView(0); and

Menu m = navigationView.getMenu();
MenuItem mi = m.getItem(index);

and then I'm able to play with items in drawer.

But in my case I have a text view that is another layout:

<item
        android:id="@+id/nav_wallet"
        android:icon="@drawable/ic_balnce"
        android:title="@string/my_wallet"
        app:actionLayout="@layout/wallet_value"/>

In my wallet_value layout I have a textView which I need to change its value, here in the image below:

enter image description here

How I can get this layout and change it?


1 Answers

Fixed with below code :-

 Menu menuView = navigationView.getMenu();
        MenuItem menuViewItem = menuView.getItem(4);
TextView walletValue =  menuViewItem.getActionView().findViewById(R.id.walletValue);

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!