back-stack

Android fragments navigation and backstack

佐手、 提交于 2019-12-30 06:18:10
问题 I have a header bar (kinda like menu) and 4 fragments (MAIN, A, B, C) from which the MAIN should be 'main/root' fragment for backstack. Problem i have is when user via menu goes for example MAIN > A > B > C. If i simply use backstack it will go in reverse order which i don't want. I need back button to go back to MAIN no matter how user navigated to one of those 3. My current code (which is wrong, it quits app when not in MAIN and current fragment is switched from other non-MAIN fragment)

WebView reloading when Fragment in ViewPager is retained form BackStack

喜你入骨 提交于 2019-12-29 04:33:47
问题 Here is a code for a basic Fragment which contains a WebView . WebFragment.java public class WebFragment extends Fragment { String TAG = "WebFragment"; private WebView webView; private String currentUrl = "http://www.google.com"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.webview_layout, null); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated

Backstack management : Restarter must be created only during owner's initialization stage

北慕城南 提交于 2019-12-28 21:41:52
问题 I am using a bottom navigation bar in my MainActivity to handle some fragments. This is the code used for switching between them: private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item -> if (item.isChecked && supportFragmentManager.findFragmentById(R.id.act_main_fragment_container) != null ) return@OnNavigationItemSelectedListener false val fragment = when (item.itemId) { R.id.navigation_home -> fragments[0] R.id.navigation_bookings ->

How to pop fragment off backstack

坚强是说给别人听的谎言 提交于 2019-12-27 20:01:27
问题 I have an activity A, which calls fragment Bf, which calls fragment Cf. I want Bf to be placed in the backstack when Cf is called so that users can navigate back to it. However, if a specific button is pressed in Cf, I would like Bf to be removed from the backstack. Is this possible? I see that there is a popBackStack() function. However, I am a little confused on how this would work. Is it safe to use this function? Is there any possibility that an activity from a different application would

How to pop fragment off backstack

孤人 提交于 2019-12-27 20:01:24
问题 I have an activity A, which calls fragment Bf, which calls fragment Cf. I want Bf to be placed in the backstack when Cf is called so that users can navigate back to it. However, if a specific button is pressed in Cf, I would like Bf to be removed from the backstack. Is this possible? I see that there is a popBackStack() function. However, I am a little confused on how this would work. Is it safe to use this function? Is there any possibility that an activity from a different application would

How to pop fragment off backstack

左心房为你撑大大i 提交于 2019-12-27 20:00:33
问题 I have an activity A, which calls fragment Bf, which calls fragment Cf. I want Bf to be placed in the backstack when Cf is called so that users can navigate back to it. However, if a specific button is pressed in Cf, I would like Bf to be removed from the backstack. Is this possible? I see that there is a popBackStack() function. However, I am a little confused on how this would work. Is it safe to use this function? Is there any possibility that an activity from a different application would

How to pop fragment off backstack

不问归期 提交于 2019-12-27 19:59:29
问题 I have an activity A, which calls fragment Bf, which calls fragment Cf. I want Bf to be placed in the backstack when Cf is called so that users can navigate back to it. However, if a specific button is pressed in Cf, I would like Bf to be removed from the backstack. Is this possible? I see that there is a popBackStack() function. However, I am a little confused on how this would work. Is it safe to use this function? Is there any possibility that an activity from a different application would

The fragment which is got from backstack, call onCreateView() again

∥☆過路亽.° 提交于 2019-12-22 04:45:10
问题 Please help me resolve my issue. I have MainActivity with a framelayout. I want to replace some fragments into the framelayout. Now I am encounering an issues, it's: 1) I created and put fragment A to framelayout. Fragment A called onCreateView ...etc. 2) Then I created and put fragment B to layout... Fragment A was put on backstack and it called onPause() (not called onDeattach() , onDestroy ...) 3) I pressed back button. Fragment A was got from backstack, but it called onCreateView() again.

Android Fragment Back Stack

大城市里の小女人 提交于 2019-12-22 03:48:14
问题 I have used multiple Fragments in my Project. I want to save a Fragment's state and restore this state when I come back to this. In this Fragment I show multiple images which change on button click. I use the following code for this: String backStateName = fragment.getClass().getName(); FragmentManager fragmentManager = getSupportFragmentManager(); boolean fragmentPopped = fragmentManager.popBackStackImmediate(backStateName, 0); if (!fragmentPopped) { FragmentTransaction fragmentTransaction =

Get all fragments from backstack in order

淺唱寂寞╮ 提交于 2019-12-21 05:16:23
问题 I am using Fragments in my app project. All the fragments are added to back stack : ... fragmentTransaction.addToBackStack(null); ... Later on, what is the correct way to get all fragments from back stack in order ? 回答1: Using the getBackStackEntryCount() you can iterate through the back stack and use the getBackStackEntryAt() method to get each Fragment. EDIT: Based on some discussions in the comments, it is advised that you manually store a list of the Fragments you have added to your