In MainActivity I have the following method that launches fragments.
@Override
public void onNavigationItemSelected(MenuItem item) {
int id = item.id;
Fragment fragmentToShow = null;
if (id != 1){
fragmentToShow = MoviesFragment.newIstance(item);
}
if (fragmentToShow != null){
launchFragment(fragmentToShow, null);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(Gravity.LEFT);
}
If the element with id = 1 is clicked, the application must open the main activity but it is not a fragment: how can i do it?
Thank you guys for your help, i am a beginner who tries to learn: surely it will be easy to solve this my problem