I was wondering - "why do others use TextUtils in many purposes?" - but I am not clear about this. The Developer site says that it is a simple string splitter. I understand this but I don't know how to use this in a practical manner or what purposes I can use it? Can anyone provide me some practical example with a code snippet?
2 Answers
one of the uses of textUtils
is for example lets say you have a string "apple,banana,orange,pinapple,mango"
which doesnt fit inside a given width it can be converted to "Apple, banana, 2 more"
.

- 2,166
- 3
- 18
- 30
-
1I like the idea, can you add some code for your answer. – Roadblock Dec 23 '16 at 07:06
-
3provide some code for implementation. – vijay chhalotre Jul 11 '17 at 06:27
-
Refer commaEllipsize (CharSequence text, TextPaint p, float avail, String oneMore, String more) part in the link below : https://stuff.mit.edu/afs/sipb/project/android/docs/reference/android/text/TextUtils.html – Sumukha Aithal K Jul 31 '18 at 10:39
It is simply a set of utility functions to do operations on String objects. In fact, the whole class doesn't have any instance fields or methods. Everything is static. Consider it like a container to group functions with a text-based semantic. Many of them could have been methods of a String inherited class or CharSequence inherited class. For example you can do:
TextUtils.indexOf(string, char)
which is the same of doing
string.indexOf(char);
Many of them do things that you can already do with string public methods. Many others add additional functionalities. This class serves at a method level the same purpose that a package serves at a class level.

- 1,891
- 13
- 19