【发布时间】:2016-01-02 06:12:51
【问题描述】:
目前,我有一个类似
的字符串
我将此字符串放入 TextView,并通过 setAutoLinkMask(Linkify.WEB_URLS) 和 setMovementMethod(LinkMovementMethod.getInstance())
但是,链接被错误识别,只有
突出显示但不突出
,并导致错误的 url。
我应该怎么做才能正确识别url?
示例结果(第二个链接被错误识别)
代码实现
txtNorm = (TextView) findViewById(R.id.txtNorm);
txtNorm.setText("http://www.example.com/defg-/");
txtNorm.setAutoLinkMask(Linkify.WEB_URLS);
txtNorm.setMovementMethod(LinkMovementMethod.getInstance());
txtCustom = (TextView) findViewById(R.id.txtCustom);
txtCustom.setText("http://www.example.com/defg-/\nletters");
txtCustom.setAutoLinkMask(Linkify.WEB_URLS);
txtCustom.setMovementMethod(LinkMovementMethod.getInstance());
【问题讨论】:
标签: java android textview pattern-matching linkify