Questions tagged [fragmentmanager]

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.

fragmentmanager
Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

supportFragmentManager not working as intended

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = UiInterfaceBinding.inflate(layoutInflater) setContentView(binding.root) taskViewModel =...
Luis Ayala's user avatar
0 votes
1 answer
29k views

java.lang.IllegalStateException: No instantiated fragment for (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) crash in Android

I rarely get a crash in my Android logs with a stack trace like this: java.lang.IllegalStateException: No instantiated fragment for (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) at android.app.ActivityThread....
georgiecasey's user avatar
  • 22.6k
0 votes
0 answers
20 views

DialogFragment listener is null after rotation

I have a Fragment that creates a DialogFragment. When user taps on the positive button or cancel/dismissed the dialog, I do something. To achieve that, I have a listener. The problem I have is that if ...
xerez's user avatar
  • 69
2 votes
2 answers
1k views

Is it possible to use both Android jetpack Compose views and xml files together in same Activity?

I am facing an issue in my Android app where I'm unable to use supportFragmentManager in my ComponentActivity subclass. As per my understanding, ComponentActivity does not support the FragmentManager ...
KZoNE's user avatar
  • 1,279
0 votes
1 answer
25 views

DialogFragment exit animation showing empty white screen

I have a DialogFragment with this code in order to animate when it exits: override fun dismiss() { dismissListener?.invoke() exitAnimation?.let { val animation = ...
htafoya's user avatar
  • 18.9k
0 votes
1 answer
105 views

FragmentManager has not been attached to a host because it was null after calling getSupportFragmentManager

I am working on an App that will have a single activity and multiple fragments. The flow will be: MainActivity with a fragment container. The initial fragment will have 4 textview buttons to display ...
Steve's user avatar
  • 11
0 votes
0 answers
33 views

How to inject the FragmentManger into interface in Android Fragment with Dagger Hilt?

I will show my sample code: interface ErrorDialogInterface { fun show(title: String) } class ErrorDialogImpl @Inject constructor( private val fragmentManager: FragmentManager ) : ...
anticafe's user avatar
  • 6,846
0 votes
0 answers
18 views

FragmentTransaction.add() issue while setting parameters for ContainerView and Fragment Class

I have tried to import android.support.v4.app.Fragment, but it doesn't allowing me to import that. This is my MainActivity enter image description here package com.example.saveload3; import android....
PRO GM's user avatar
  • 1
0 votes
0 answers
26 views

AndroidX and FragmentManager

I am updating an older App to use AndroidX and moving it to VS2022. In my code, I have the following code: AndroidX.Fragment.App.FragmentTransaction ft = FragmentManager.BeginTransaction(); ft.Replace(...
Dan Dickerson's user avatar
0 votes
0 answers
17 views

how can i use correct context in date picker in fragment

i am newbie in Kotlin.i think that happen Caused by context but i cant solve it class FragmentDatePicker : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {...
mahta.hdri's user avatar
0 votes
0 answers
295 views

Fatal Exception: java.lang.IllegalStateException: FragmentManager has been destroyed in Android 13

Fatal Exception: java.lang.IllegalStateException: FragmentManager has been destroyed (Android Kotlin) I got this crash on my firebase crashlytics for my app, and it happens too many times. The ...
Gerald Sapphire's user avatar
1 vote
0 answers
28 views

FragmentTransaction.add(0, request); crashes for android:compileSdkVersion="26" or above

I started learning android development and am still not that familiar with Java code. I would like to request permission dynamically using the following code which is from http://www.bytran.org/...
danka's user avatar
  • 19
0 votes
0 answers
36 views

Fragment with Recycleview shows blank sometimes

I have one fragment(A) with two links, clicking each one will jump to a new fragment (B or C), the code (in onCreateView or onResume method) for jumping to the fragment B or C is as below. ...
Eric's user avatar
  • 303
0 votes
2 answers
289 views

IllegalArgumentException: No view found for id when using getChildFragmentManager() inside viewpager2

My app structure look like this - (Main Activity)->(Fragment 1)->(ViewPager-> Fragment A,Fragment B). I am getting error when i do fragment transaction inside Fragment A or B like this. ...
Ritu's user avatar
  • 668
0 votes
0 answers
458 views

Fragment not associated with a fragment manager after screen rotation in Android

I have a problem I can't solve. I have two fragments, one called "NotificationListFragment" that can navigate to a second fragment called "InfoNotificationFragment". Before calling ...
Davide's user avatar
  • 1
0 votes
0 answers
199 views

android: no view found for id for fragment

I'm sorry for posting a question on the subject again but this is driving me crazy. I have a fragment and I'm adding views programmatically to a LinearLayout: <LinearLayout ...
jack_the_beast's user avatar
0 votes
0 answers
52 views

Android. Is there way to invert order of adding Fragments to LinearLayout?

I have a fragment containing LinearLayout, where programmaticaly added fragments using: getFragmentManager().beginTransaction().add(R.id.linear_layout, CheckTemplateFragment.newInstance(*params*)....
Toasted_Donut's user avatar
0 votes
0 answers
66 views

Navigating from one fragment to another using Fragment manager in kotlin

I am trying to navigate from one fragment to another using Fragment Manager but the app exits when the button is clicked. I tried a few solutions from the internet but I am still not able to figure ...
Jayashree K's user avatar
1 vote
0 answers
327 views

java.lang.IllegalArgumentException: No view found for id 0x7f0800c4

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textview=findViewById(R.id.textView); Button ...
Soumyadeep Paul's user avatar
1 vote
1 answer
2k views

How to use fragmentcontainerview in java?

I have a container inside MainActivity like that <fragment android:id="@+id/main" android:name="androidx.navigation.fragment.NavHostFragment" ...
devio's user avatar
  • 674
-1 votes
2 answers
245 views

can not resolve method add for Fragment Transaction - Android

I was just upgrading old android project and stuck at below code : FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.add(R.id....
Jaimin Modi's user avatar
  • 1,620
-1 votes
1 answer
609 views

ViewPager2 Error Fragment Manager is already executing

I am trying to fix a bug where my app crashes if a user performs an orientation change during the onboarding process (I used a 3 fragment viewpager2 layout within JetPack NavHost). I tried adding my ...
CoolHands's user avatar
2 votes
1 answer
477 views

supportFragmentManager.findFragmentById returning null

The code I have posted below works when the activity is part of main app. However, when I import the project (of which the activity is a part of) as a library into another project and call the ...
K K's user avatar
  • 73
0 votes
0 answers
108 views

With a change of configuration, the fragments are not redesigned

When there is a configuration change, such as uiMode, Locale, etc., the fragments are not restored correctly. Then simply put the application in the background, and then return to the foreground, and ...
Fiorenza Francesco's user avatar
2 votes
0 answers
73 views

Fragment add exit custom animation not working working when fragment is Added Android

The custom exit animation works for replace but not for add getNavFragment() .childFragmentManager .beginTransaction() .setCustomAnimations( enter, exit,...
Sharan's user avatar
  • 1,205
1 vote
1 answer
391 views

Can FragmentResultListener used with the same request key in multiple fragments?

I have FragmentA(nav_graph_a), which navigates to FragmentB(nav_graph_b). FragmentB navigates to a DialogFragment, which call setFragmentResult(RK_SHARED). Both FragmentA and FragmentB registers a ...
Andras Sanislo's user avatar
1 vote
0 answers
574 views

How to Migrate to the Navigation library from FragmentManager

I want to make an app with a BottomNavigationView which has a single activity, which would contain a FragmentContainerView where all the fragments would be hosted. I am trying to understand how ...
Matey Krastev's user avatar
1 vote
1 answer
223 views

TypeError: Cannot read property 'getFragmentManager' of undefined

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getFragmentManager' of undefined. This error is popping when I run my nativescript angular application. It says something wrong in ...
Naveen Kumar's user avatar
2 votes
1 answer
733 views

Kotlin android app crashes because of coroutines

I'm developing my first app and learning as I go. The app communicates with a URL to fetch data, and sometimes to send data in a POST. Since my last gradle update to 7.1.1, my app is crashing when I ...
sazira's user avatar
  • 31
0 votes
0 answers
581 views

App crashes when pressing back button while on viewpager

App seems to crash when I press the virtual back button on android. Viewpager2 setup in fragment: val viewPager = view.findViewById<ViewPager2>(R.id.pager) val tabLayout = view.findViewById<...
konstantin veljanovski's user avatar
0 votes
1 answer
31 views

Fragment in TabView issue in Android

I have Pager which has two Fragments, class eTransactionPager(fm: FragmentManager) : FragmentStatePagerAdapter(fm) { override fun getCount(): Int = 2 override fun getItem(position: Int): ...
F_Z's user avatar
  • 591
0 votes
1 answer
854 views

How to prevent FragmentManager from being destroyed after rotation

When I click the show more button a new fragment opens. However if I rotate the device and then click it I get an error. E/AndroidRuntime: FATAL EXCEPTION: main Process: com.rekijan....
Rekijan Kileren's user avatar
0 votes
2 answers
1k views

Xamarin, C#, when using AndroidX, how do you get your activity's default FragmentManager to use the AndroidX version not the old one?

I have AndroidX in my Xamarin Android project. In https://learn.microsoft.com/en-us/xamarin/android/platform/fragments/managing-fragments, the article says each activity has it's own FragmentManager ...
karhukoti's user avatar
0 votes
1 answer
440 views

How to Avoid Race Condition in FragmentManager?

My goal is to allow only one single instance of the same dialog fragment in the fragment stack. The current trigger condition is coming from a SharedFlow and can be triggered as often as 7ms apart ...
You Qi's user avatar
  • 8,865
0 votes
1 answer
39 views

How can I display a fragment without creating a new one?

I have an app with a bottom navigation menu and it uses a switch case to change the fragment that is displayed public boolean onNavigationItemSelected(@NonNull MenuItem item) { ...
michael ip's user avatar
0 votes
1 answer
1k views

.commitNow() vs .commit(), which is more adequate?

I´m trying to clean up my code and I have a more basic question. In my Activity, I'm just adding a Fragment -> class OrderActivity : AppCompatActivity(), HasAndroidInjector { private lateinit ...
Nicote Ool's user avatar
0 votes
2 answers
435 views

Navigation action/destination /action_creditTabFragment_to_needHelpFragment cannot be found from the current destination Destination(creditFragment)

My app uses navigation component, I have CreditFragment and it uses TabLayout with ViewPager2, it contains CreditTabFragment, when I am at the CreditTabFragment I want to navigate to NeedHelpFragment ...
Marcelo Junior's user avatar
2 votes
3 answers
1k views

How to prevent creating 2 instances of same fragment?

I have an activity (MainActivity) that contains MasterFragment which contains a viewpager with FragmentA and FragmentB in portrait screen orientation. In landscape mode the viewpager contains only ...
user3115340's user avatar
0 votes
0 answers
1k views

Fragment not attached to an activity

Hello im trying to start a new login fragment if the condition is true but dont know how the same code was working perfectly fine and im able to get the login fragment when the condition is true from ...
Vasant Raval's user avatar
0 votes
1 answer
128 views

Android Studio FragmentManger POP_BACK_STACK_INCLUSIVE

I'm imitating a project to study, and the original study, activity?.supportFragmentManager!!.popBackStack(activity?.supportFragmentManager!!.getBackStackEntryAt(0).id, POP_BACK_STACK_INCLUSIVE) it ...
SDH's user avatar
  • 3
1 vote
1 answer
657 views

Communicate from ChildFragment to Parent when parent button's onClick

I have a parent Fragment that has inside a FragementContainerView in which there is a transition of different Fragments. The parentFragment has a button that when is clicked it has to collect all the ...
mantc_sdr's user avatar
  • 461
0 votes
1 answer
68 views

Problem with selected Item on fragment binding

I'm trying to make a Toast indicating the selected Item so I used this but when I run the application it shuts down. Do you know the correct way for doing this? Thank you override fun onViewCreated(...
MeowYOU's user avatar
2 votes
0 answers
114 views

No view found for id 0x7f0800be (com.example.progetto:id/fragment_container_view) for fragment HomeFragment{xx} (xxxx id=0x7f0800be tag=HomeFragment)

I've read these questions/answers: Android Fragment no view found for ID? No view found for id for fragment java.lang.IllegalArgumentException: No view found for id 0x1020002 (android:id/content) for ...
Sara Briccoli's user avatar
5 votes
5 answers
2k views

bottom navigation view fragment re-created when it is already created

In my application i am using Jetpack Navigation with BottomNavigationView. I have like 4 fragments:Home,Search,Notifications,Profile and when i am in Home fragment, i click again home item in bottom ...
nasibeyyubov's user avatar
  • 2,205
0 votes
1 answer
62 views

Popbackstack always returns previous call

I've got three Simple Fragments: FragmentA, FragmentB, FragmentC. FragmentA -> FragmentB: FragmentB fragment2 = new FragmentB (); FragmentManager fragmentManager = getActivity()....
Funny Moments's user avatar
0 votes
1 answer
311 views

Declared target fragment that does not belong to this FragmentManager

I've got a simple setup: Code: ActivityHaupt -> FragmentHaupt: final FragmentHaupt fragment = new FragmentHaupt(); final FragmentTransaction transaction = getSupportFragmentManager()....
Nummer Eins's user avatar
0 votes
1 answer
136 views

Problem replacing Fragment within another one. (fragments overlapping)

I try go to SaveRouteFragment from RecordRouteFragment. The result is that both fragments are overlapping on each other. I was searching Internet and didn't find an anwer to my issue, although some ...
James121's user avatar
1 vote
1 answer
1k views

Fragment Transaction is added to backstack even if disallowAddToBackStack is called

Here is a sample code to repo this bug: If I replace 3 fragments in a row, and disable the second one to be added into the backstack. fragmentManager = supportFragmentManager val ...
Qing's user avatar
  • 1,411
14 votes
4 answers
17k views

setFragmentResult doesn't work onClick listener

hello my problem is the following, I have 2 fragments, one receives with SetFragmentResultListener and another sends with setFragmentResult The problem is that setFragmentResult does not work inside ...
Sebastian Labadie's user avatar
0 votes
1 answer
1k views

Opening a fragment from another fragment within same bottom navigation activity in Android [duplicate]

I am trying to replace a fragment with another fragment in my Bottom Navigation Activity. I want to achieve this on the click of a button in my fragment. but I am getting the following error: java....
Levi's user avatar
  • 205

1
2 3 4 5
14