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()
{
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.