I am trying to split the line on the pipe, read how it is all done, but I can not understand what is wrong. Does not work.

Trying to split this line:

String test="23535|ghgdfh"; 

When I print this line in the text, then there are no problems:

 TextView test_text = (TextView)findViewById(R.id.test_text); test_text.setText(test); 

I am trying to make a guide

 TextView test_text = (TextView)findViewById(R.id.test_text); test_text.setText(test.split("|")); 

As a result, the studio swears at the cannot resolve method. Where do I make a mistake? And what can you read about this issue? Strings for dummies or something like that

  • split will return an array, and setText will probably take a string. Why break a string into an array and immediately display it? - Grundy
  • @Grundy Well, I just simplified the question. I get two variables on bluetooth, separated by a pipe. I want to pull these variables out of the line and work further with them separately - Cotton Pericranium
  • For the future, format the Java code with the “Sample Code” button ( {} ), and not with the “JavaScript / HTML / CSS Code Fragment” button. The latter is intended only for interactive examples in the listed languages ​​that can be displayed directly in the browser. - default locale
  • one
    @defaultlocale Yes, sir!) - Cotton Pericranium

1 answer 1

Thanks to Grundy for the tip. Need to work with a string, not with an array

 test_text.setText(Arrays.toString(test.split("\\|")));