4

How to bypass the text limitations of a TextView element?

 2 years ago
source link: https://www.codesd.com/item/how-to-bypass-the-text-limitations-of-a-textview-element.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to bypass the text limitations of a TextView element?

advertisements

Apparently there seems to be a text length limit on the TextView element when used within a ListView. I have to admit I have not checked the actual limit that I am facing, but it is clear to me that 2k characters is no biggie, where 4k characters is simply not being displayed. And "not displayed" is not even right, as the screen seems to be scrollable for the full length of the TextView (although all I get to see is whitespace).

My issue: I am displaying a ListView for an email message. All parts of the mail are in seperate TextView elements that get dropped into the ListView. When a lengthy message (somewhere above 2k characters) is put into a TextView, the TextView remains empty but does occupy space.

My question: What alternatives/options are there to make this problem go away? Eg Making the entire message displayable (even long ones).

Thanks to anyone in advance for assistance.


Is there any reason you have to use a ListView? It seems like you'd be better served with a LinearLayout or RelativeLayout inside a ScrollView, or maybe just put the body of the email inside a ScrollView if you want to keep the other TextViews on the screen.

If you want to stick with the ListView, you might consider using String#substring(int beginIndex, int endIndex) to ellipsize the body and show the full body in another Activity launched in the onListItemClick handler for the list view. You can use the android:ellipsize property in your XML layout (or TextView#setEllipsize in Java code) to limit the text to a single line, but that is probably not what you want.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK