0
我是一个文本设置为一个TextView调用的Android的TextView:文本,如果不从的setText HTML和android显示:单线=“真”
tv.setText(Html.fromHtml("<a href=\"" + link + "\">" + text + "</a>"));
这个文本是一个网络链接。
这是工作的罚款,直到我自己剪的文字。 现在,我已经设置:
android:singleLine="true"
android:ellipsize="end"
到TextView的,文本不再可见。
它是一个已知的问题还是什么?
编辑:
让别人更好地理解这个问题,我详细解释发生了什么事:
这是我的TextView:
<TextView
android:id="@+id/txtEventRecipient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="true"
android:focusable="false"
android:gravity="center"
android:linksClickable="true"
android:padding="5dp"
android:textColor="@drawable/elv_title_1_selector"
android:textSize="@dimen/small_text_size"
android:textStyle="bold"
android:typeface="normal" />
这哪里设置文本代码作为链接:
TextView tv = (TextView) convertView.findViewById(R.id.txtEventRecipient);
String userName = "<a user name got from somewhere>";
// here I was cutting the userName as it's length must fit
if (userName.length() > 16)
userName = userName.substring(0, 15) + "…";
// here I set the link to the user
tv.setText(Html.fromHtml("<a href=\"" + link + "\">" + userName + "</a>"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
这是工作,但与一个可怕的固定16
作为最大长度,所以我决定用“singleLine”使它更具动感。
的singleLine="true"
导致不显示文本作为HTML链接的问题。
“我自己剪了文字” - 这是什么意思?另请注意,不推荐使用'android:singleLine'。使用'android:maxLines =“1”'。 – CommonsWare
'if(userName.length()> 16) userName = userName.substring(0,15)+“...”;' – marco
在您的问题中'setText()'调用中没有'userName'。请修改您的问题,向我们显示**完全不适合您的代码**。 – CommonsWare