-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid child view for SegmentedButtonGroup. Only SegmentedButton's are valid children of the group #31
Comments
Hello, Sorry, but I only sort of understand what's going on here. Basically, the issue is that SegmentedButtonGroup can only have SegmentedButton directly as children. See here for the source code: I'm confused as to why a non-SegmentedButton is being added to the group? I don't see anywhere in your provided code where that would occur. |
Thanks For a Quick Response. So I Override that throw expression, will it resolve the crash at least. Since I am not adding or removing any view other than Segmented Button, I do not think it will be an issue If override throw statement with toast or something like it. |
The crash is happening while creating or destroying fragment 5 or 6thtime |
Hmm. So does commenting out the throw work? For debugging purposes, I'd be interested in seeing what the child being added actually is. You might try just setting a breakpoint there or something |
I have toasted the type of view it turned out to be FrameLayout.
Screen is attached below Crash went away though |
Okay, that's interesting. Here are my thoughts:
Can you log the addView function and record each time it is called to see what's going on? I would recommend seeing what the View is an instance of. If it's a SegmentedButton, you could try getting the text in the button too. I might also recommend adding the I think this will give us much more clarity as to what's going on. |
I am facing the issue of application crash on replacing the host fragment Of Segmented Buttons
Below is my Layout configuration for the Segmented Button Group.
Below Snippets Define The Usage inside fragments
The Initialization
The Position Changed Listener
The Crash Stack is as below (SegmentedButtonGroup.java:507)
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.atomicskills.chatteach, PID: 30039 java.lang.IllegalArgumentException: Invalid child view for SegmentedButtonGroup. Only SegmentedButton's are valid children of the group at com.addisonelliott.segmentedbutton.SegmentedButtonGroup.addView(SegmentedButtonGroup.java:507) at android.view.ViewGroup.addView(ViewGroup.java:4960) at androidx.transition.TransitionUtils.createViewBitmap(TransitionUtils.java:138) at androidx.transition.TransitionUtils.copyViewImage(TransitionUtils.java:64) at androidx.transition.Visibility.onDisappear(Visibility.java:401) at androidx.transition.Visibility.createAnimator(Visibility.java:257) at androidx.transition.Transition.createAnimators(Transition.java:747) at androidx.transition.TransitionSet.createAnimators(TransitionSet.java:480) at androidx.transition.Transition.playTransition(Transition.java:1821) at androidx.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:301) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1088) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2898) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1821) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7916) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:980) at android.view.Choreographer.doCallbacks(Choreographer.java:804) at android.view.Choreographer.doFrame(Choreographer.java:739) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:965) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:7510) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
Also, I am using Add() of fragment transaction for the first time and replace the other times In A bottom Navigation view.
Before I used Hide Show Approach for fragment Transactions, It was working fine in that scenario.
The text was updated successfully, but these errors were encountered: