0
linkify을 사용하여 텍스트보기에서 URL과 전자 메일을 강조 표시하면 첫 번째 렌더링시 올바르게 작동하지만 텍스트가 작동하지 않을 때 올바르게 작동합니다.
내 텍스트보기 나는 spannable을 사용하여 더 많이보고 더 적은 텍스트 길이가 특정 문자열보다 길 때 볼 수 있습니다. 지금은 일이있어 때까지이linkify not work when update text
post_data.setMovementMethod(LinkMovementMethod.getInstance());
post_data.setLinkTextColor(Color.BLUE);
Linkify.addLinks(post_data, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
를 추가 텍스트를
private static SpannableStringBuilder getTextToShown(Activity activity, String text, boolean showMore) {
SpannableStringBuilder sb;
final ForegroundColorSpan fcs = new ForegroundColorSpan(activity.getResources().getColor(R.color.cyan_mostly_black_light));
String textToShow;
if (!showMore) {
textToShow = text + " " + activity.getResources().getString(R.string.see_less);
sb = new SpannableStringBuilder(textToShow);
sb.setSpan(fcs, text.length(), textToShow.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), text.length(), textToShow.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
textToShow = text.substring(0, NUMBER_OF_CHAR_TO_SHOWN - 1) + " " + activity.getResources().getString(R.string.see_more);
sb = new SpannableStringBuilder(textToShow);
sb.setSpan(fcs, NUMBER_OF_CHAR_TO_SHOWN, textToShow.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), NUMBER_OF_CHAR_TO_SHOWN, textToShow.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return sb;
}
를 추가 다음 내 스팬 기능을하고 난 다음
if (postModel.getObject().getContent().length() > 140) {
post_data.setText(getTextToShown(activity, postModel.getObject().getContent(), true));
showMore = true;
post_data.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (showMore) {
post_data.setText(getTextToShown(activity, postModel.getObject().getContent(), false));
showMore = false;
} else {
post_data.setText(getTextToShown(activity, postModel.getObject().getContent(), true));
showMore = true;
}
}
});
} else {
post_data.setText(postModel.getObject().getContent());
}
하여 사용하고 난에 의해 linkify 추가 문제없이 잘됐지만 클릭 할 때 textview에서 더 많이 봅니다. 텍스트 뷰에서 새로운 텍스트를 렌더링하지만 링크 또는 emai를 강조 표시하지 않습니다. 나는 UI 스레드에서 실행하려고하지만 동일한 결과를 얻습니다. 어떤 도움이 필요합니까? 는 XML
android:textColorLink="@color/blue.pure"
android:autoLink="all"
및 사용에 다음과 linkify
을 제거하고 만 추가로