Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 374
Pankaj Kumar Avatar asked Dec 27 '22 23:12

Pankaj Kumar


2 Answers

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.

like image 99
Bill Mote Avatar answered Jan 31 '23 02:01

Bill Mote


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

or ellipsize ?

like image 26
Reno Avatar answered Jan 31 '23 02:01

Reno