제 작품에서는 각 목록보기 항목에 맞춤 링크 (사용자 정의 태그 사용)를 추가해야합니다. 두 가지 문제를 만났으며 Google 및 stackoverflow에서 검색했습니다. 결과는 없습니다 ...ListView의 textView에 HTML을 추가 할 때의 두 가지 문제점
다음은 코드 세그먼트이며 TagHandler로 태그를 처리합니다.
TextView tv = (TextView)paramView.findViewById(R.id.tv_dynamics_desc);
tv.setClickable(true);
tv.setText(Html.fromHtml("<uc id=\"133\">This is a Uc link</uc>", null, this));
tv.setMovementMethod(LinkMovementMethod.getInstance());
첫 번째 문제는 속성 ID를 얻는 방법입니다.
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
if(tag.toLowerCase().startsWith("uc")) {
if (opening) {
//String id = xmlReader.getProperty("id").toString(); <=== to get the attribute, but failed with exception of no such property.
startClick(tag, output, xmlReader);
} else {
endClick(tag, output, xmlReader);
}
}
}
xmlReader.getProperty ("ID")로 .toString(); 여기서는 효과가 없습니다. 그래서 태그를 "uc + id"(uc133과 같이)로 변경하면 약간의 문제는 있지만 문제가 해결됩니다.
속성을 직접 가져 오는 방법이 있습니까?
두 번째는 항목 또는 링크의 다른 부분을 터치해도 터치 이벤트를받을 수없는 목록보기 항목입니다.
Artem Russakovskii는 덧글 here에서도이 문제를 만났다고 말했다.
나는 중국 출신이기 때문에 불쌍한 영어를 유감스럽게 생각합니다.
정말 감사합니다 :)