是否有一种方法可以改变autoLink TextView的检测发现电话号码的方式?
问题是,它可以很好地检测国际格式,比如+49123456789,但是在本地格式化的数字(如0699777666555 )上失败(没有前面的"+“字符)。
我们也需要有这些号码。
TextView是用autoLink="all"设置的
<TextView
android:id="@+id/chat_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... some other settings ...
android:autoLink="all"
android:linksClickable="true"
android:textColorLink="@color/darkblue"
android:textColor="@color/black"/>我们有内部号码(比如5532)和本地电话号码,没有像12345678这样的前缀。如果它们也能被突出显示,没有任何,或者至少没有太多的编码,那就太好了。
有什么解决办法吗?提前感谢!
发布于 2016-09-29 08:00:10
尝试以编程方式这样做:
public class AutoLinkifyTextView extends TextView {
public AutoLinkifyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public AutoLinkifyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void setText(String text) {
super.setText(text);
parseLinks();
}
@Override
public void setText(int stringRes) {
super.setText(stringRes);
parseLinks();
}
private void parseLinks() {
Linkify.addLinks(this, Linkify.ALL);
}
}然后使用AutoLinkifyTextView代替TextView
https://stackoverflow.com/questions/39764397
复制相似问题