大佬教程收集整理的这篇文章主要介绍了android – 正确使用TextUtils.commaEllipsize,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在谷歌搜索中找到的唯一一件事是test unit for the TextUtils class.
一些指导将不胜感激.
编辑:
我查看了我在这里得到的答案并尝试在我的代码上实现它.我使用了这段代码:
TextView title = (TextView) view.findViewById(R.id.listitemThreadstitlE); title.setVisibility(View.VISIBLE); TextPaint p = title.getPaint(); String strtitle = "Moe,Joe,Isaac,Bethany,Cornelius,Charlie"; title.setText(strtitlE); float avail = p.measureText(strtitlE); CharSequence ch = TextUtils.commaEllipsize(strtitle,p,avail,"one more","%d more"); title.setText(ch);
但结果绝对不是它应该是的.
它更像是:Moe,Betha ……
而不是:Moe,Isaac 3
public static CharSequence commaEllipsize (CharSequence text,TextPaint p,float avail,String oneMore,String morE)
参数:
text – 要截断的文本
p – 用于测量文本的Paint
avail – 文本可用的水平宽度
oneMore – 当前语言环境中“1 more”的字符串@H_764_32@more – 当前语言环境中“%d more”的字符串
String text = "Apple,Orange,Mango,Banana"; TextView tv = new TextView(context); float textWidth = tv.getPaint().measureText(text ); String tempStr = TextUtils.commaEllipsize(text,tv.getPaint(),textWidth,"1 more","%d more"); tv.setText(tempStr);
更新:
TextView title = (TextView) view.findViewById(R.id.listitemThreadstitlE); title.setVisibility(View.VISIBLE); TextPaint p = title.getPaint(); String strtitle = "Moe,Charlie"; title.setText(strtitlE); float avail = title.getMeasuredWidth(); CharSequence ch = TextUtils.commaEllipsize(strtitle,"%d more"); title.setText(ch);
以上是大佬教程为你收集整理的android – 正确使用TextUtils.commaEllipsize全部内容,希望文章能够帮你解决android – 正确使用TextUtils.commaEllipsize所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。