开发者

android Linkify first occurrence only

开发者 https://www.devze.com 2023-01-07 22:25 出处:网络
i am using Linkify with a custom TransformFilter. 开发者_运维知识库 Is it possible to tell linkify to only match the first occurence of my pattern?I would use a MatchFilter for that, like this

i am using Linkify with a custom TransformFilter. 开发者_运维知识库 Is it possible to tell linkify to only match the first occurence of my pattern?


I would use a MatchFilter for that, like this

   MatchFilter matcher = new MatchFilter() {
        boolean firstTime;
        @Override
        public boolean acceptMatch(CharSequence s, int start, int end) {
            if(firstTime) {
                return true;
                firstTime = false;
            } else {
                return false;
            }
        }
    };

Hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消