Skip to content

NullPointerException when using tooltip 2 times #28

@khrizt

Description

@khrizt

Hi, I'm trying to use the tooltip library on 2 different activities of my project and when the 2nd should be shown this exception appears:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:525)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
    at android.view.View.layout(View.java:15654)
    at android.view.ViewGroup.layout(ViewGroup.java:4969)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2102)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1859)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1078)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    at android.view.Choreographer.doFrame(Choreographer.java:550)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5376)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

The code I'm using is

Tooltip.make(itemView.getContext(),
                     new Tooltip.Builder()
                             .withStyleId(R.style.ToolTipLayoutCustomStyle)
                             .anchor(itemView.findViewById(R.id.detail_choice_optionA), Tooltip.Gravity.BOTTOM)
                             .closePolicy(new Tooltip.ClosePolicy()
                                     .insidePolicy(true, false)
                                     .outsidePolicy(true, false), 5000)
                             .activateDelay(1500)
                             .showDelay(300)
                             .text(itemView.getResources().getString(R.string.tooltip_choice_text))
                             .maxWidth(400)
                             .withArrow(true)
                             .withOverlay(true)
                             .floatingAnimation(Tooltip.AnimationBuilder.DEFAULT)
                             .build()
                ).show();

Any hint what's happening? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions