ANDROID Navigation view drawer menu 1 item selected
<p>I have 3 menus in my navigation view where each menu have few more items.
Im having problems when i press each item in menu, i want checked item to be selected but other items non selected.
Bellow is picture so that you can see what is the problem:</p>

<p>For selection im using item.setChecked(true); in onNavigationItemSelected(MenuItem menu).
What i want is only 1 item to be selected, so when i checked one item, i want that other items are not selected.</p>

<p>I search on google but usually they say that i need to separate each menu into  group android:checkableBehavior="single" what i done but, it still do not work:</p>

<p><strong>EDIT START:</strong></p>

<p>I just find solution, instead of <strong>item.setChecked(true)</strong> i write <strong>navigationView.setCheckedItem(R.id.itemId);</strong> and everything works now.</p>

<p><a href="https://stackoverflow.com/questions/31233279/navigation-drawer-how-do-i-set-the-selected-item-at-startup">I find solution on this link:</a></p>

<p><strong>EDIT END</strong></p>

<p><a href="https://i.stack.imgur.com/D6Dwx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D6Dwx.jpg" alt="enter image description here"></a></p>

<p>Here is the code for drawer_menu.xml:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;

    &lt;item android:title="Animals"&gt;
        &lt;menu&gt;
            &lt;group android:checkableBehavior="single"&gt;
                &lt;item
                    android:id="@+id/dog"
                    android:icon="@drawable/ic_action_dog"
                    android:title="Domestic Animals" /&gt;

                &lt;item
                    android:id="@+id/wild"
                    android:icon="@drawable/ic_action_dog"
                    android:title="Wild Animals" /&gt;

                &lt;item
                    android:id="@+id/bird"
                    android:icon="@drawable/ic_action_bird"
                    android:title="Birds" /&gt;

                &lt;item
                    android:id="@+id/fish"
                    android:icon="@drawable/ic_action_fish"
                    android:title="Sea Animals" /&gt;

                &lt;item
                    android:id="@+id/insects"
                    android:icon="@drawable/ic_action_bubamara"
                    android:title="Insects" /&gt;
            &lt;/group&gt;
        &lt;/menu&gt;
    &lt;/item&gt;

    &lt;item android:title="Others"&gt;
        &lt;menu&gt;
            &lt;group android:checkableBehavior="single"&gt;
                &lt;item
                    android:id="@+id/car"
                    android:icon="@drawable/ic_action_car"
                    android:title="Cars" /&gt;


                &lt;item
                    android:id="@+id/smiley"
                    android:icon="@drawable/ic_action_smiley"
                    android:title="Laugh" /&gt;

                &lt;item
                    android:id="@+id/earth"
                    android:icon="@drawable/ic_action_earth"
                    android:title="Nature" /&gt;

                &lt;item
                    android:id="@+id/sounds"
                    android:icon="@drawable/ic_action_zvucnik"
                    android:title="Effects" /&gt;

                &lt;item
                    android:id="@+id/tools"
                    android:icon="@drawable/ic_action_clock"
                    android:title="Others" /&gt;

            &lt;/group&gt;
        &lt;/menu&gt;
    &lt;/item&gt;

    &lt;item android:title="Change pictures"&gt;
        &lt;menu&gt;
            &lt;group android:checkableBehavior="single"&gt;
                &lt;item
                    android:id="@+id/change_picture_id"
                    android:icon="@drawable/ic_action_promjena_slike"
                    android:title="Change Picture"&gt;&lt;/item&gt;
            &lt;/group&gt;
        &lt;/menu&gt;
    &lt;/item&gt;

&lt;/menu&gt;</code></pre>
</div>
</div>
</p>

<p>Here is the code for navigation drawer menu item click events in main activity:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>     navigationView = (NavigationView) findViewById(R.id.navigation_view);

        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem item) {

                switch (item.getItemId()) {
                    case R.id.dog:
                        homeFragment.sortiranje("Domestic", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.wild:
                        homeFragment.sortiranje("Wild", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.bird:

                        homeFragment.sortiranje("Birds", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.fish:
                        homeFragment.sortiranje("Sea", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.insects:
                        homeFragment.sortiranje("Insects", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.car:
                        homeFragment.sortiranje("Cars", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.smiley:
                        homeFragment.sortiranje("Laugh", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.earth:
                        homeFragment.sortiranje("Nature", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.sounds:
                        homeFragment.sortiranje("Effects", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.tools:
                        homeFragment.sortiranje("Others", tagonja);
                        item.setChecked(true);
                        drawerLayout.closeDrawers();
                        break;
                    case R.id.change_picture_id:
                        item.setChecked(true);
                        if (tagonja == 0) {
                            tagonja = 1;
                            homeFragment.promjenaSlike(tagonja);
                        } else if (tagonja == 1) {
                            tagonja = 0;
                            homeFragment.promjenaSlike(tagonja);
                        }

                        drawerLayout.closeDrawers();

                        break;
                }

                return false;
            }
        });</code></pre>
</div>
</div>
</p>