Jéwôm'
Jéwôm'

Reputation: 3971

android.view.View not valid because waiting for a View type

I try to use the sephiroth74/android-target-tooltip library for my project but an argument is not valid...

This is what I do (in a fragment) :

Button btn = (Button) view.findViewById(R.id.btn);

        Tooltip.make(getContext(),
                new Tooltip.Builder(101)
                        .anchor(btn, Gravity.BOTTOM)
                        .closePolicy(new Tooltip.ClosePolicy()
                                .insidePolicy(true, false)
                                .outsidePolicy(true, false), 3000)
                        .activateDelay(800)
                        .showDelay(300)
                        .text("test")
                        .maxWidth(500)
                        .withArrow(true)
                        .withOverlay(true)
                        .floatingAnimation(Tooltip.AnimationBuilder.DEFAULT)
                        .build()
        ).show();

The problem is in this line :

anchor(btn, Gravity.BOTTOM)

It seem btn is not a good argument :

Cannot resolv method 'anchor(android.wiget.Button, int)'

If I try to change by :

anchor(view.findViewById(R.id.btn), Gravity.BOTTOM)

I have :

Cannot resolv method 'anchor(android.view.View, int)'

What can I do ? This function is waiting for a View type but how can I give a View type with my Button ?

Upvotes: 0

Views: 68

Answers (1)

Gaurav Sarma
Gaurav Sarma

Reputation: 2297

I think I understand your issue. The issue is with the Gravity, which is being imported from a wrong class i.e. in your case you must have

import android.view.Gravity;

in your import section whereas it should be

import it.sephiroth.android.library.tooltip.Tooltip;

So, basically just replace the import line and your builder should look like this

new Tooltip.Builder(101) 
    .anchor(btn, Tooltip.Gravity.BOTTOM)
....
....

Upvotes: 1

Related Questions