0

I have a menu in my android app, I am loading this menu in a NavigationView. I need change the background only in a item. I read the menu items and which I have to change the background from a json file form the server.

I tried this solution.

How to customize item background and item text color inside NavigationView?

It works but I have a problem. When I select one option (without different background) it item get checked state and the background change to this item.

I tried to reset states when I close the menu (next code), but it doesn't work.

for (int i = 0; i < mNavigationView.getMenu().size(); i++) {
        if (specialItem == mNavigationView.getMenu().getItem(i)) {
            mNavigationView.getMenu().getItem(i).setChecked(true);
        } else {
            mNavigationView.getMenu().getItem(i).setChecked(false);
        }
    }

How I could reset the menuItem state to initial state when I close the menu?

Is it a good solution? could I solve it easily with other way?

Sorry for my English

Thank you

Gautam Surani
  • 1,136
  • 10
  • 21
lexell
  • 123
  • 1
  • 1
  • 8

0 Answers0