Pankaj Kumar
Pankaj Kumar

Reputation: 82958

TextView setText problem

I have a TextView and my need is to add 10 characters in that TextView by code. But when characters are greater than 10, they should be display in TextView but with 8 character + .. of that charsequence. And when I want to read text of that TextView I must get full charsequence not 8 character + .. . For example

tv.settext("ASDFGHJKLQ") // this is 10 characters long, so no rule required

but

tv.settext("ASDFGHJKLOP") // this is more than 10 characters then it should be display as ASDFGHJK.. in textView, but when I retrieve the value of textview, it should return ASDFGHJKLOP instead of ASDFGHJK.. , so how can it be done.

That textView is row of a listview.

Upvotes: 4

Views: 1373

Answers (3)

Reno
Reno

Reputation: 33792

This truncating happens because it does not fit in your list item. Reduce the font ?

or ellipsize ?

Upvotes: 4

Bill Mote
Bill Mote

Reputation: 12823

Try adding this to your TextView (marquee or end):

android:ellipsize="marquee"

You may also need:

android:scrollHorizontally="true"

Without scrollHorizontally="true" you may still get the text wrapped rather than appended with ... I use these very 2 lines to display a list view in my app. The 3 long lines I have get appended correctly.

Upvotes: 5

Tima
Tima

Reputation: 12905

I see only one solution. But maybe there are another solutions.

To store you string.

If string's length is greater than 10 letters set text of your TextView with 12345678..

And if you want to get right text you should take the value of the string and not of the textview.

Upvotes: 1

Related Questions