Reputation: 82958
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
Reputation: 33792
This truncating happens because it does not fit in your list item. Reduce the font ?
or ellipsize ?
Upvotes: 4
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
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