博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android基础教程——在TextView中显示Html 自定义标签,获取标签属性
阅读量:7005 次
发布时间:2019-06-28

本文共 1220 字,大约阅读时间需要 4 分钟。

In my work, I have to add custom links (use custom tag) in each listview item. I met two problems and have searched by Google and stackoverflow, but no result... Here is the code segment and I process the tag with TagHandler.

TextView tv = (TextView)paramView.findViewById(R.id.tv_dynamics_desc);tv.setClickable(true);tv.setText(Html.fromHtml("
This is a Uc link
", null, this));tv.setMovementMethod(LinkMovementMethod.getInstance());

The  problem is how to get the attribute: id.

@Overridepublic 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(); does not work here. Is there any way to get the attribute directly? the ansow is "yes". but I don't know now~! I met the same problem and i will save it and record it at here!  

转载于:https://www.cnblogs.com/smallerpig/archive/2013/05/20/3646079.html

你可能感兴趣的文章
Go编码规范
查看>>
【web开发】☆★之利用POI操作Excel表格系列教程【7】Excel文本取值
查看>>
360手机卫士界面布局学习过程续(四)
查看>>
360手机卫士界面布局学习过程续(二)
查看>>
maven导入本地jar的方法,亲测可用
查看>>
Wechat SDK
查看>>
Introducing the Dreamweaver CS5 HTML5 Pack
查看>>
我的友情链接
查看>>
日常运维工作shell脚本案例
查看>>
SVN学习笔记二——客户端使用
查看>>
spring Bean的生命周期
查看>>
[Oracle]1 -- 基本登录退出文件引用
查看>>
mysql text类型
查看>>
菜鸟学Linux 第064篇笔记 ftp概念,vsftp配置
查看>>
广告坑死人,这年头如何辨别互联网金融的可靠性?
查看>>
其实,今天写这篇文章的目的,是给我的博客“破处”
查看>>
tableView使用的各项注意点
查看>>
千里之行,始于足下——Shell scripts
查看>>
主板开启AHCI模式后不能进入win7系统
查看>>
用MDT 2012为企业部署windows 7(十三)--结合WDS部署部署windows 7客户端
查看>>