android-simple-tooltip
android-simple-tooltip copied to clipboard
verify dismissed? Tooltip has ben dismissed.
hi, here's a small code, on a custom modal, double tapping the button... java.lang.IllegalArgumentException: Tooltip has ben dismissed.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById(R.id.btn_modal_custom).setOnClickListener(this)
val textView1: TextView? = TextView(this)
val textView2: TextView? = TextView(this)
textView1!!.text = "Yout text here"
textView2!!.text = "some more text"
val layout: LinearLayout? = LinearLayout(this)
layout!!.addView(textView1)
layout.addView(textView2)
val view:View = findViewById(R.id.btn_modal_custom)
val tooltip = SimpleTooltip.Builder(this)
.anchorView(view)
.text(R.string.btn_modal_custom)
.gravity(Gravity.BOTTOM)
.modal(true)
.animated(true)
.animationDuration(2000)
.contentView(layout, 0)
.focusable(true)
.build()
view.setOnClickListener({
if (tooltip.isShowing) {
tooltip.dismiss()
} else
{
tooltip.show()
}
})
}
I think I do not understand, what's the problem?
@Fahad-pnw you should instead be using something like (sorry code is in java because I do not have time to convert it in kotlin so its kinda like pseudocode).
val tooltip = SimpleTooltip.Builder(this)
.anchorView(view)
.text(R.string.btn_modal_custom)
.gravity(Gravity.BOTTOM)
.modal(true)
.onDismissListener(new SimpleTooltip.OnDismissListener() {
@Override
public void onDismiss(SimpleTooltip tooltip) {
listener.onTooltipDismissedForView(view.getId());
}
})
.animated(true)
.animationDuration(2000)
.contentView(layout, 0)
.focusable(true)
.build()
Here, onTooltipDismissedForView(@IdRes viewId)
is just a callback. This way you could perhaps detect which view the tooltip was dismissed for, instead of setting a OnclickListener
for every view.
based on the documentation provided, you should not take action from variables that have been defined before calling. You can directly create the object when you want to do a show action
view.setOnClickListener({
SimpleTooltip.Builder(this)
.anchorView(view)
.text(R.string.btn_modal_custom)
.gravity(Gravity.BOTTOM)
.modal(true)
.animated(true)
.animationDuration(2000)
.contentView(layout, 0)
.focusable(true)
.build()
.show()
})