How to call screens by NavigationDrawerFragment in FragmentActivity?

0

I have a class that extends FragmentActivity to call the map, and other classes that are only Fragment . How do I make the method to call the screens by NavigationDrawerFragment ?

    
asked by anonymous 27.09.2014 / 15:11

1 answer

1

In your class where you have the navigation drawer create a method similar to this

public void selectItem(int position) {
    int title = 0;
    fragment = null;
    boolean withTabs = false;
    switch (position) {
    case 1:
        title = R.string.tipu_title;
        fragment = new MainFragment();
        withTabs = true;
        break;
    }
    if (title != 0) {
        setTitle(title);
    }
    mDrawerLayout.closeDrawer(menuList);    
    if (position != currentPosition) {
        setCurrentPage(fragment, withTabs);
        currentPosition = position;
    }
}

Then in the classes where you want to go to another fragment, just call it that way

 ((ClasseNavigationDrawer)getActivity()).selectItem(position);
    
29.09.2014 / 15:16