Taking String values and separating them

Asked

Viewed 38 times

0

Ex.:

(Textview)result = "text1;text2;text3;text4" ;

I want to take them in sequence and do it this way, so that I can manipulate them separately.

String tx1 = "text1";
String Tx2 = "text2";
String tx3 = "text3";
String tx4 = "text4";

  • I have read and "I think" that the "index" method does this, but I don’t know how to use :S

1 answer

2


Do so:

String [] pedaços = resultado.split(";");

Each item of the array pedaços you will have one of the strings between semicolons. Example:

Log.v("Teste", "Texto 1 = " + pedaços[0]); // Imprime Texto 1 = texto1
  • Perfect guy :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.