Reputation: 1752
I'm setting a text to a TextView calling
tv.setText(Html.fromHtml("<a href=\"" + link + "\">" + text + "</a>"));
This text is a web link.
This was working fine till I cut the text by myself. Now that I've set:
android:singleLine="true"
android:ellipsize="end"
to the TextView, the text is not visible anymore.
Is it a known issue or what ?
EDIT:
To let others better understand the problem, I explain in details what was happening:
This was my 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" />
This the code where I set the text as link:
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());
This was working but with a horrible fixed 16
as max length so I decided to make it more dynamic with the "singleLine".
The singleLine="true"
is causing the problem not showing the text as HTML link.
Upvotes: 0
Views: 267
Reputation: 1006634
android:singleLine
has been more-or-less deprecated for a while. It only infrequently works. android:maxLines="1"
is more typical nowadays.
Upvotes: 1