我正在寻找一些关于如何正确使用它的示例代码TextView
。
我在 Google 搜索中发现的唯一东西是TextUtils 类的这个测试单元。
一些指导将不胜感激。
编辑:
我查看了我在这里得到的答案,并尝试在我的代码中实现它。我使用了这个代码片段:
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、Joe、Isaac + 3