I have tried to develop retrieving the count value from soap webservices and display them to android emulator. Here I have mentioned particular textview means it is not display on my emulator. Why this is not display on my emulator. Please help me. Which line I have to change.
This is my android code:
public class RetailerActivity extends Activity {
private static final String SOAP_ACTION = "http://xcart.com/data";
private static final String METHOD_NAME = "data";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://192.168.1.168:8085/XcartLogin/services/RetailerWs?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.retrieve);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");//Result string will split & store in an array
TextView tv = (TextView) findViewById(R.id.textView1);
// TextView tv = new TextView(this);
for(int i = 0; i<resultArr.length;i++){
tv.append(resultArr[i]+"\n\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Here i have to wrote TextView tv = new TextView(this); line means the output is displayed.but i have to put dis line TextView tv = (TextView) findViewById(R.id.textView1); means the output is not display on my emulator.
Remove this line
setContentView(tv);. I don’t seem to find it correct to use twosetContentView()here.Because you have already called the
setContentView(R.layout.retrieve);in the first place and you have initialized your TextView here,So,
alone should work. No need to set
tvagain.EDIT 1
Your TextView in xml should be something like this,.
Remove other attributes,.