突出显示clickablesspan单击 [英] Highlight on clickablespan click

查看:109
本文介绍了突出显示clickablesspan单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没什么问题,我需要在单击clickablespan期间删除或自定义此橙色突出显示.这是我的类,扩展了ClickableSpan

I've got little problem, i need to remove or customize this orange highlight during clicking on clickablespan. This is my class extending ClickableSpan

public class InternalClickableSpan extends ClickableSpan {

    private String clicked;

    @Override
    public void updateDrawState(TextPaint ds) {
        ds.setUnderlineText(false);
    }

    public InternalClickableSpan(String clickedString) {
        clicked = clickedString;
    }

    @Override
    public void onClick(View view) {
        Selection.setSelection((Spannable) ((TextView)view).getText(), 0);
        Toast toast = Toast.makeText(mContext, clicked, Toast.LENGTH_SHORT);
        toast.show();
    }
}

这就是我在文本视图中使用它的方式

and this is how i use it on text view

Spannable spans = (Spannable) tv.getText();      
spans.setSpan(new InternalClickableSpan(contacts[i]), text.indexOf(contacts[i]),   text.indexOf(contacts[i])+contacts[i].length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

有人知道如何自定义跨度对象的"onclick高亮"吗?

Does anybody know how to customize "onclick highlight" on spannable object?

edit:感谢Aleadam的答复,我正在重写updateDrawState(请查看我的InternalClickableSpan类中的第一个方法),但无论如何我都找不到自定义此功能的方法.还有其他想法吗?谢谢

edit: Thanks Aleadam for response, i'am overriding updateDrawState (please take a look at the first method in my InternalClickableSpan class), but i can't find a way to customize this higlight anyway. Has anybody got other ideas? Thanks

推荐答案

您可以像这样覆盖onClick(View widget):

        @Override
        public void onClick(View widget) {
            // do what must happen after click event.
            widget.invalidate();
        }

这篇关于突出显示clickablesspan单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆