I have an overriding method with String which returns String in format of:
"abc,cde,def,fgh"
I want to split the string content into two parts:
String before first comma and
String after first comma
My overriding method is :
@Override
protected void onPostExecute(String addressText) {
placeTitle.setText(addressText);
}
Now how do I split the string into two parts, so that I can use them to set the text in two different TextView
?
Combining TRIM, MID, SUBSTITUTE, REPT, and LEN functions together helps us to split a string separated by commas into several columns. Just follow the steps below to do this. First, enter 1, 2, and 3 instead of columns titles ID No., LastName, and Dept. Now, write down the following formula in an empty cell C5.
Use Split to break up comma delimited lists, dates that use a slash between date parts, and in other situations where a well defined delimiter is used. A separator string is used to break the text string apart.
Use Split to break up comma delimited lists, dates that use a slash between date parts, and in other situations where a well defined delimiter is used. A separator string is used to break the text string apart. The separator can be zero, one, or more characters that are matched as a whole in the text string.
In this example, we will take a string with chunks separated by comma ,, split the string and store the items in a list. If you use String.split () on String with more than one comma coming adjacent to each other, you would get empty chunks.
You may use the following code snippet
String str ="abc,cde,def,fgh";
String kept = str.substring( 0, str.indexOf(","));
String remainder = str.substring(str.indexOf(",")+1, str.length());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With