question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ballon with custom layout: removeView exception

See original GitHub issue

Please complete the following information:

  • Library Version: 1.4.0
  • Affected Device(s): Pixel 4, Android 12

Describe the Bug:

When running the following code with a custom Layout:

balloon = new Balloon.Builder(TiApplication.getAppCurrentActivity())
                .setArrowSize(arrowSize)
                .setLayout(customView)
                .setArrowOrientation(orientation)
                .setArrowPositionRules(ArrowPositionRules.ALIGN_BALLOON)
                .setArrowPosition(0.5f)
                .setWidth(BalloonSizeSpec.WRAP)
                .setHeight(BalloonSizeSpec.WRAP)
                .setCornerRadius(4f)
                .setAlpha(0.9f)
                .setArrowColor(arrowColor)
                .setBalloonAnimation(BalloonAnimation.ELASTIC)
                .setLifecycleOwner(lifecycle)
                .build();

I receive this error when calling it the second time:

[ERROR] TiExceptionHandler:     android.view.ViewGroup.addViewInner(ViewGroup.java:5247)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.addView(ViewGroup.java:5076)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.addView(ViewGroup.java:5016)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.addView(ViewGroup.java:4988)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon.initializeCustomLayout(Balloon.kt:594)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon.initializeBalloonLayout(Balloon.kt:576)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon.createByBuilder(Balloon.kt:194)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon.<init>(Balloon.kt:187)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon.<init>(Balloon.kt:131)
[ERROR] TiExceptionHandler:     com.skydoves.balloon.Balloon$Builder.build(Balloon.kt:2533)
[ERROR] V8Exception: Exception occurred at /alloy/controllers/index.js:191: Uncaught Error: The specified child already has a parent. You must call removeView() on the child's parent first.

There was am older issue https://github.com/skydoves/Balloon/issues/149 that already fixed some places. This might be another one.

Expected Behavior:

No expception, being able to create another ballon with me options.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
m1gacommented, Dec 4, 2021

Ok, that is an embarrassing easy fix 🤣 Works fine now. Thank you so much for your help 👍

1reaction
m1gacommented, Dec 4, 2021

It’s a bit more complicated 😄 I’m creating a module for Appcelerator Titanium so you can create your views in XML/JS and show it with the help of your module https://github.com/m1ga/ti.popover/tree/main/android/src/ti/popover Relevant files are PopoverProxy (connection between JS and Java) and PopoverView (create native Views).

Inside PopoverView I’m receiving the Titanium View (TiUIVIew) as a parameter and get it’s native View.

Then after that the Balloon part is here.

So I have to make sure somehow that my layout doesn’t have any more parents? In fact I had a version running once where it opened every click but I ended up in getting a new balloon arrow add to my view every time.

Later on in Titanium you wrap the content of the popup like this

<Popover module="ti.popover" id="popover">
    <View id="contentView">
        <ImageView id="img"/>
        <Label text="test" id="lbl"/>
    </View>
</Popover>

and can run

$.popover.show({
	view: cv,
	direction: direction
})

but don’t want to bother you with framework insides 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fatal Exception: java.lang.IllegalStateException #149 - GitHub
You must call removeView() on the child's parent first. at android.view.ViewGroup. ... showAsDropDown(PopupWindow.java:1380) at com.skydoves.balloon.
Read more >
Balloon information on google maps in android - Stack Overflow
android-mapviewballoons library provides an easy way to annotate map overlay items with a simple information balloon when using Google Maps.
Read more >
Chapter 4. Screen and UI Performance - O'Reilly
As a developer, your task is to work with the UI/UX team and build an app that follows its design parameters on every...
Read more >
Android™ Application Development
Using Layouts. 79. Creating New Views. 80. Modifying Existing Views. 81. Creating Compound Controls. 85. Creating Custom Widgets and Controls.
Read more >
TechDraw VerticalExtentDimension - FreeCAD Documentation
The Vertical Extent Dimension tool adds a linear dimension to a View. The dimension extends from the bottom most point on the selected ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found