我试图开发从肥皂网络服务中检索计数值并将它们显示到 android 模拟器。在这里,我提到了特定的 textview 意味着它不会显示在我的模拟器上。为什么这不在我的模拟器上显示。请帮我。我必须改变哪条线。这是我的安卓代码:
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();
}
}
}
在这里我必须写 TextView tv = new TextView(this); line 表示显示输出。但我必须输入 dis line TextView tv = (TextView) findViewById(R.id.textView1); 表示输出未显示在我的模拟器上。