how to split textview into two values android code example

Example 1: split string to textview in android

String data = "1,Diego Maradona,Footballer,Argentina";
String[] items = data.split(",");
for (String item : items)
{
    System.out.println("item = " + item);
}

Example 2: split string to textview in android

String s = "Some St., Some City, Some post code";
    String strings[] = s.split(",");

      for(int i = 0; i < strings.length; i++){
         strings[i] = strings[i].trim();
         strings[i] += ",\n";
      }
      s = "";

      for(int i = 0; i < strings.length; i++)
        s += strings[i];

Tags:

Java Example