I have an app with a NavigationDrawer
.
I'm loading a Fragment from a Fragment(throught a onClick event of a button), but I can't find how to change the the item selection of the ListView
of the NavigationDrawer corresponding to the Fragment.
I tryed to do:
final View navigationView = inflater.inflate(R.layout.fragment_navigation_drawer,container,false);
ListView lista = (ListView) navigationView.findViewById(R.id.listMenu);
lista.setFocusable(true);
lista.setFocusableInTouchMode(true);
lista.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lista.performItemClick(lista, 2, lista.getItemIdAtPosition(2));
lista.setItemChecked(2,true);
lista.setSelection(2);
lista.requestFocus();
...after the FragmentTransaction commit(), but the ListView
item selected is not changing.
Is there any way to change the selected item by code?
or
Is there any way to invoke a click in the ListView of NavigationDrawer so onNavigationDrawerItemSelected can be executed?
Thanks!
SOLVED changing accessibility to public of the ListView mDrawerListView at NavigationDrawerFragment Class. The extendend explanation in the answer at bottom