링크 클릭 사용자 지정
1421 단어 click
2. If textview is linkable, get all URLSpan from the Spannable text. Use the URLSpan to construct you custom ClickableSpan.
example:
TextView tv =(TextView)this.findViewById(R.id.textview);
CharSequence text = tv.getText();
if(text instanceof Spannable){
int end = text.length();
Spannable sp = (Spannable)tv.getText();
URLSpan[] urls=sp.getSpans(0, end, URLSpan.class);
SpannableStringBuilder style=new SpannableStringBuilder(text);
style.clearSpans();//should clear old spans
for(URLSpan url : urls){
MyURLSpan myURLSpan = new MyURLSpan(url.getURL());
style.setSpan(myURLSpan,sp.getSpanStart(url),sp.getSpanEnd(url),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
tv.setText(style);
}
private static class MyURLSpan extends ClickableSpan{
private String mUrl;
MyURLSpan(String url) {
mUrl =url;
}
@Override
public void onClick(View widget) {
//do what you want with the mUrl
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
OutClick 구현을 위한 Vue 명령의 예원시적 실현 다음은 두 가지 흔히 볼 수 있는 모드 프레임의 실현 방식이다 방안 1: 기본 클릭은 거품을 막는 단계에 놓여 있습니다. 내용 영역에 클릭을 추가하면 거품을 막을 수 있습니다. 시나리오 2: 터치한 DO...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.