android-fragments

Fragment, save large list of data on onSaveInstanceState (how to prevent TransactionTooLargeException)

风格不统一 提交于 2021-02-18 05:22:14
问题 In my app, I have Fragment which is inside ViewPager. Fragment contains RecyclerView with list of data fetched from web api based on user selection. On my Fragment onSaveInstanceState I save list data to Bunde, to keep the data on configuration changes etc. public void onSaveInstanceState(Bundle savedState) { super.onSaveInstanceState(savedState); savedState.putParcelableArrayList(LIST_STORAGE_KEY, new ArrayList<>(mItemAdapter.getModels())); } Now I have started to see

Fragment no longer exists for key FragmentStateAdapter with Viewpager2

一世执手 提交于 2021-02-17 21:54:33
问题 I am using ViewPager2 for my project. I need to use nested fragments inside a fragment with viewpager2. it works like charm until I try to navigate between fragments(not nested ones). After the first time navigating between fragments, the application crash with the error explained below. the fragment which contains nested fragments OnCreateView method: View view = inflater.inflate(R.layout.orders_fragment, null); ViewPager2 viewPager = view.findViewById(R.id.childViewPager); TabLayout tabs =

Passing an Object to Fragment or DialogFragment upon Instantiation

痴心易碎 提交于 2021-02-17 21:36:32
问题 I'm trying to work out the correct way to pass in an Object to a Fragment or DialogFragment without breaking the 'empty constructor' rule. For example I have created a custom View and for each one I instantiate I want to associate a DiaglogFragment. This DialogFragment will be used to display controls with which the user can alter certain aspects of the custom View it is associated with. Because View is an Object I understand I cannot use setArguments(). I could implement a newInstance(View)

Android: How to swipe between activities (not fragments), master/detail best set-up

本小妞迷上赌 提交于 2021-02-17 21:00:14
问题 I'm working on an android app and I'm fairly new to all this, including mobile app development, so I have a few questions. Any help would be amazing! 1) Is it possible to swipe between entire activities (including action bar)? And I don't mean like viewPager swapping between fragments, I mean swapping the entire screen (like snapchat does on iOS). Is this possible at all? And if so, how can I do this? 2) What is the best way to implement a master/detail type layout? Like twitter for instance,

What is the differences between onAttach() and isAdded() in android Fragment?

好久不见. 提交于 2021-02-17 07:16:11
问题 Can anyone tell me what are the different of use of onAttach() and isAdded in Android Fragment? When create a new fragment onAttach() method creating default. I checked this question, the question is asked about !onDetech() and isAdded() , also one answer there, but I am not clear with that.. Thanks 回答1: This could be answered simply reading javadocs: /** * Called when a fragment is first attached to its context. * {@link #onCreate(Bundle)} will be called after this. */ public void onAttach

What is the differences between onAttach() and isAdded() in android Fragment?

♀尐吖头ヾ 提交于 2021-02-17 07:16:09
问题 Can anyone tell me what are the different of use of onAttach() and isAdded in Android Fragment? When create a new fragment onAttach() method creating default. I checked this question, the question is asked about !onDetech() and isAdded() , also one answer there, but I am not clear with that.. Thanks 回答1: This could be answered simply reading javadocs: /** * Called when a fragment is first attached to its context. * {@link #onCreate(Bundle)} will be called after this. */ public void onAttach

BottomNavigation Menu with Jetpack Navigation does not navigate

旧巷老猫 提交于 2021-02-11 17:36:06
问题 I have a strange problem regarding a BottomNavigationBar which I could not solve altough having spent a huge amount of time into it. When I use it in the 'recommended' way (from many tutorials) it just does not navigate. So what do I mean by 'recommended' way: I have a single acticity with a navHostFragment called 'MainActivity'. This main activity has a XML layout file in which I put the BottomNavigationBar. The BottomNavigationBar also has a XML layout file. Now I have a Fragment called 'FR

Generated binding class that only takes a LayoutInflater as its sole argument

随声附和 提交于 2021-02-11 16:45:42
问题 The generated binding class from the Android Data Binding library has different versions of the inflate method: One that looks like the usual LayoutInflater.inflate method that takes a viewGroup and attachToRoot parameter, and one that only takes a LayoutInflater and nothing else. The documentation doesn't explain the difference between the two and unfortunately Android Studio doesn't let me step through the source code of inflate so that I could figure out which values it is using internally

Android send Data from fragment to Activity

笑着哭i 提交于 2021-02-11 15:57:38
问题 I'm working on an Android app, I get some datas in a fragment and I want to use them in an other fragment. So I was looking to create a bundle, get it in the activity with a simple getBasicInfos() method that return my bundle then send it to my other fragment. But the problem is I can't use this method in my activity. fragment = new DashboardFragment(); fragment.getBasicInfos(); //Does not recognize the method toolbar.setTitle(getResources().getString(R.string.dashboard)); break; I want to