Actually I am trying to fetch data from a URL and have to split that data string using the split("@") method and have to set that data in TextView.
It’s running without error, but it is showing nothing.
enter code here
package com.androidpeople.view;
import java.io.BufferedReader;
import java.io.IOException;``
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class WebViewExample extends Activity {
String element1,element2,element3,element4,element5,element6;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView text1=(TextView) findViewById(R.id.textView1);
TextView text2=(TextView) findViewById(R.id.textView2);
TextView text3=(TextView) findViewById(R.id.textView3);
TextView text4=(TextView) findViewById(R.id.textView4);
TextView text5=(TextView) findViewById(R.id.textView5);
TextView text6=(TextView) findViewById(R.id.textView6);
String nextLine;
URL url = null;
URLConnection urlConn = null;
InputStreamReader inStream = null;
BufferedReader buff = null;
// Create the URL obect that points
// at the default file index.html
if (nextLine !=null){
String aColors[] = nextLine.split("@");
element1= aColors[0];
element2= aColors[1];
element3= aColors[2];
element4= aColors[3];
element5= aColors[4];
element6= aColors[5];
}
}
}
catch(IOException e){
e.printStackTrace();
}
text1.setText("text is" +element1);
text2.setText("text is" +element2);
text3.setText("text is" +element3);
text4.setText("text is" +element4);
text5.setText("text is" +element5);
text6.setText("text is" +element6);
}
}
I think Split method have to use like this :
Hope it helps.