0

I'd like to shorten the text out if it's too long and add "..." at end. This is the example where I would like to clip the text:

enter image description here

I've tried multiple variations of code (TruncateAt.END, .setLines(4), ...) but I think this should work:

textv.setMaxLines(4);
textv.setEllipsize(TruncateAt.MARQUEE);

But the result is this:

enter image description here

What is wrong?

4

1 に答える 1

0

文字列の部分文字列を取得し、それを最大長として使用して、最後に ... を追加できます。

int MAX_LENGTH=40;
if(inString.length > MAX_LENGTH)
    View.setText(inString.subString(0,MAX_LENGTH) + "...";

これがあなたを助けることを願っています...

于 2012-05-23T19:38:12.720 に答える