douglasjunior / android-simple-tooltip

A simple library based on PopupWindow to create Tooltips on Android. 💚
MIT License
796 stars 192 forks source link

Dismiss on button click #54

Closed sajadmaster closed 7 years ago

sajadmaster commented 7 years ago

Let's say I have added this tooltip to a button view. Now I want to dismiss this tooltip only after I click the button. There are only two ways to dismiss this tooltip:

  1. dismissOnInsideTouch
  2. dismissOnOutsideTouch

Is there any other way to dismiss this tooltip inside another view's click listener? for example:

final SimpleTooltip.Builder tut1 = new SimpleTooltip.Builder(this);
        tut1.anchorView(loveGoalMeterIV)
                .text("Texto do Tooltip")
                .gravity(Gravity.BOTTOM)
                .animated(true)
                .transparentOverlay(false)
                .dismissOnInsideTouch(false)
                .dismissOnOutsideTouch(false)
                .build()
                .show();

ImageView loveGoalMeterIV = findViewById(R.id.loveGoalMeterIV);

loveGoalMeterIV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                   tut1.hide()
            }
        });
douglasjunior commented 7 years ago

Try:

final SimpleTooltip tooltip = new SimpleTooltip.Builder(this)
                .anchorView(loveGoalMeterIV)
                .text("Texto do Tooltip")
                .gravity(Gravity.BOTTOM)
                .animated(true)
                .transparentOverlay(false)
                .dismissOnInsideTouch(false)
                .dismissOnOutsideTouch(false)
                .build();

tooltip.show();

ImageView loveGoalMeterIV = findViewById(R.id.loveGoalMeterIV);

loveGoalMeterIV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                   tooltip.dismiss();
            }
        });
sajadmaster commented 7 years ago

Worked like a charm! Thanks for the prompt reply :)