How to change Navigation Item Selected programmatically
<p>When I created a new project I used <strong>Navigation Drawer Activity</strong> 
<a href="https://i.stack.imgur.com/UVWk6.jpg" rel="nofollow noreferrer">app screen</a></p>

<p>Now each menu item when I click on it will open a fragment by calling a method name replacement.</p>

<pre><code>    public boolean onNavigationItemSelected(MenuItem item) {
            // Handle navigation view item clicks here.
            int id = item.getItemId();

            if (id == R.id.nav_home) {
                replaceFragment(0);
                setTit = "Your State Info.";
                setTitle(setTit);
 } else if (id == R.id.nav_flashcards) {

            replaceFragment(1);
            setTit = "Flash Cards";
            setTitle(setTit);
</code></pre>

<p>in fragment 1 I have a RadioGroup when the checked change will open the fragmet depends on the radio checked.</p>

<pre><code> @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {

        RadioButton radioButton = (RadioButton)getActivity().findViewById(i);

            if(radioButton.getTag()==1)
        ((MainActivity) getActivity()).replaceFragment(0);
           else if ((radioButton.getTag()==2))
             ((MainActivity) getActivity()).replaceFragment(2);
    }
</code></pre>

<p>The App work fine , but the issue is how can I change the Navigation Item Selected and also change the title for the action bar.</p>

<p>it's possible to use this way</p>

<pre><code> ((MainActivity) getActivity()).onNavigationItemSelected(menuitem);
</code></pre>

<p>but from the fragment how can I access the the items in the <strong>menu>activity_main_drawer.xml</strong> and pass it through menuitem</p>