Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I am beginner in android studio.
In a application in android, There is a main page that has some tabs in bottom,(such as home, profile, help, faq, ...). In any tab there are nested pages. For example in profile tab, nested pages are: edit profile, change pic,...
By click on back button, it just come back nested pages of current tab.
If nested pages are fragments, It look like that stack for each tab is separate of other tabs.
I get some tabs and nested pages of them as fragments. and for return code:
<pre>public static boolean recursivePopBackStack(FragmentManager fragmentManager) {
        if (fragmentManager.getFragments() != null) {
            for (Fragment fragment : fragmentManager.getFragments()) {
                if (fragment != null && fragment.isVisible()) {
                    boolean popped = recursivePopBackStack(fragment.getChildFragmentManager());
                    if (popped) {
                        return true;
                    }
                }
            }
        }

        if (fragmentManager.getBackStackEntryCount() > 0) {
            fragmentManager.popBackStack();
            fragmentManager.executePendingTransactions();
            return true;
        }

        return false;
    }

 public void close_handler() // a function that show alert dialog for closing
    // program
    {

        if (!recursivePopBackStack(getSupportFragmentManager())) {
            super.onBackPressed();
        }
}


But by click on back button It return all nested fragment of all tab.

How can I implement such application?
Thanks

What I have tried:

Implementing nested pages for each tab and back button. How can I do it?
Return back for nested fragments of the specific tab.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900