Android: displaying part of a message in a TextView
I have a list view where each list item is a message with a sender/recipient, date, and content. I want to display the sender/recipient in the top left, the date in the top right, and the content on another line below. My proble开发者_如何学Pythonm is that if either the name or content is too long I want to be able to cut off the string and end it with an ellipsis (...). Is there any way to do this?
Thanks for any help!
You can use
android:ellipsize="end"
Or programmatically
myTextView.setEllipsize (TextUtils.TruncateAt.END);
For my details: android:ellipsize
Use java! You could add extra features, like detecting the end of a word.
if (mystring.length() > LIMIT) {
mystring = mystring.substring(0, LIMIT) + "...";
}
精彩评论