How to call the screens by the Navigationdrawerfragment in Fragmentactivity?

Asked

Viewed 277 times

0

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

  • Anderson, could you include the code of your Activity and of NavigationDrawer who made?

1 answer

1

In your class where you have 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 Ragment is just to call it that way

 ((ClasseNavigationDrawer)getActivity()).selectItem(position);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.