FragmentManager is an interface for interacting with Fragment objects inside an Activity in Android. While the FragmentManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity. For more information about using fragments, read the Fragments developer guide.
Questions tagged [fragmentmanager]
700 questions
5
votes
1 answer
android.support.v4.app.FragmentManager and android.app.FragmentManager in ViewPager
guys.
I develop an app for Android API 14 and higher but I want to use ViewPager that comes in Android Support Library.
ViewPager needs FragmentPagerAdapter that uses android.support.v4.app.FragmentManager in the constructor. But within my…

Slava
- 1,225
- 2
- 9
- 9
4
votes
1 answer
How to use FragmentFactory with arguments at runtime?
Let's say i have a fragment with constructor that gets an argument at runtime depending on a network request for instance
class MyFragment(private val myArg: Int) : Fragment() {
// Do layout and other stuff
}
I did a sample FragmentFactory to…

Thracian
- 43,021
- 16
- 133
- 222
4
votes
1 answer
Listening to Fragment onClicks in Main Activity
In the main activity im making a PagerAdapter and populating it with Fragments. Now I want to listen to click in the main Activity. How can I do that?
The part from main Activity.
ViewPager viewPager = (ViewPager)…

Richard
- 1,087
- 18
- 52
4
votes
2 answers
Fragment with ViewPager having blank pages after returning to it from another fragment
In my application I'm trying to create 2 fragments with ViewPagers. The fragments have 3 tabs/pages each with RecyclerViews and they are supposed to be backed by a database, so I'm keeping them in a List.
class MainActivity : AppCompatActivity() { …

Jakub Dąbek
- 1,044
- 1
- 8
- 17
4
votes
1 answer
findFragmentById for a viewpager, of a tab, returns the same fragment regardless of the fragment displayed
I have a tab with two fragments. Regardless of the tab that is selected,
getSupportFragmentManager().findFragmentById(R.id.container)
returns the id of the fragment in the second tab every time.
I experimented and added another tab, repeating one…

cokeinpepsibottle
- 55
- 1
- 6
4
votes
5 answers
How to get current fragment from MainActivity
I've done some research but I really couldn't find the answer.
I have single activity with side menu, and holder. I have many (non support) fragments, and all of them are using same holder (one at a time).
When user uses menu (it's in main…

Mohamed
- 1,251
- 3
- 15
- 36
4
votes
2 answers
Reloading fragment, Edittext's text not cleared
In my fragment there are lot of spinner and edit text and submit button is to save data, reset button is to reset all elements(Edit Texts and Spinners). I have used folllowing code to reset all controls
FragmentTransaction ft =…

Rajesh N
- 6,198
- 2
- 47
- 58
4
votes
1 answer
Get FragmentManager inside AndroidViewModel
AndroidViewModel is used to access Application context. I'm trying to access Activity's FragmentManager without passing it explicitly:
class FooViewModel(app: Application) : AndroidViewModel(app) {
private val fm = (app.applicationContext as…

0leg
- 13,464
- 16
- 70
- 94
4
votes
3 answers
FragmentTransaction won't Compile in Kotlin Android Project
In the process of learning Kotlin with Android, the failure to compile and generally unhelpful error text have left me stumped. The error text says the following:
None of the following functions can be called with the arguments
supplied.…

Josh Ribeiro
- 1,349
- 3
- 18
- 28
4
votes
0 answers
Why am I getting IllegalStateException: FragmentManager is already executing transactions
There are a several questions addressing that error but none of them have had a fix that worked for this situation.
Whats happening is that we are popping a fragment (which is nested inside a featureFragment) and making a call back to the activity…

Dan Anderson
- 1,062
- 13
- 26
4
votes
1 answer
Tracking Fragment Lifecycle like Application.ActivityLifecycleCallbacks
Everyone knows that in Android we can track Activities via Application.ActivityLifecycleCallbacks to obtain fires from system, when Activity created, stopped, destroyed, etc.
I found only one question on stackoverflow related to this theme.
Hooking…

Sergey Shustikov
- 15,377
- 12
- 67
- 119
4
votes
2 answers
Poping the backstack without causing illegalStateException
I was getting
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
in my code and i searched statckoverflow i got the below code as solution.
Now i am not getting IllegalStateException but the problem is.. below…

kumar
- 708
- 4
- 15
- 39
4
votes
1 answer
Parent Fragment is alive in Child Fragment but Activity is Null
I have a child fragment in which , parent fragment stays alive but activity context gets null in some random conditions otherwise it works fine,
My child fragment code is as follows,
package cl.tt.ui.fragments.child;
import…

Abhinandan Chada
- 139
- 5
4
votes
3 answers
How to pass variables with Android fragmentmanager
I have the following simple code to switch from one fragment to another in the content frame. Is there a simple way to pass variables in the following code?
FragmentManager fm =…

J.J.
- 1,128
- 2
- 23
- 62
4
votes
1 answer
Cannot resolve for method show(android.app.FragmentManager, java.lang.String)
I've on API 23.Using RadialTimePickerDialogFragment that uses v4
The parent activity is based on Activity (we don't need
Why am I getting
Cannot resolve for method show(android.app.FragmentManager,
java.lang.String)
import…

Drawn
- 435
- 1
- 7
- 20