How to detect when back button pressed in fragment android?
问题 I have project with navigation drawer with fragment, with 5 menu, the problem is when i go to menu 4 and the i press the back button the app closed, but i need the app back to first menu which is all the menu in fragment. This is code for Main Activity (Navigation Drawer) public class MainActivity extends AppCompatActivity{ DrawerLayout mDrawerLayout; NavigationView mNavigationView; FragmentManager mFragmentManager; FragmentTransaction mFragmentTransaction; @Override protected void onCreate