• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trim string to shorter length

 
Steven Mann
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I trim a string to a shorter length and add ellipses? I seem to recall a method that does that...
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use String#subString(..) method and then append ellipsis character.

May I ask why you want to do this?

The reason why I am asking this question is that I speculate you want to display this string in a TextView and if the string is longer, you want to truncate it and display ellipsis. If so, there is a property named ellipsize which needs to be set to true.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic