• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android .split not working correctly

Hi the code below doesn't seem to be working correctly is there something I'm doing wrong?



Basically what happens is I receive the string prd|50126057|12bars|5 and I'm trying to split it up into three different textViews; when I run it it only shows prd in the first textView and the others don't change. Why does this happen?


I can see it working in the logs it is just not displaying it in the other textviews.


Any help is much appreciated and thanks in advance.


Also I'm sorry if this has already been answered i did do some searching on here but couldn't find anything.


[HIGH]
public void messageReceived(String message) {

String response = message;
String[] words = response.split("\\|");

TextView tv1 = (TextView) findViewById(R.id.textView1);
TextView tv2 = (TextView) findViewById(R.id.textView2);
TextView tv3 = (TextView) findViewById(R.id.textView3);

tv1.setText(words[0]);
tv2.setText(words[1]);
tv3.setText(words[2]);

Log.e("items-->", "" + words[0] + " " + words[1] + " " + words[2]+ " " + words[3]);

publishProgress(message); } });[/HIGH]
 
Back
Top Bottom