-1
私はSOAPを使用しています、AsyncTaskクラスでは、私はドライバIDText、shipmentIDText、freightShipment textviewsのテキストを設定しようとしていますが、setText()あなたは文字列ではないのTextViewとしてdriverIDTextを宣言し、だから、TextViewのために1つの以上のparamを作成し、onPostExecuteでのTextViewのデータをOnCreate関数からdriverIDText(のTextView)を送信し、設定私はクラスのTextViewのテキストを設定できません
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_up);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TextView driverIDText = (TextView) findViewById(R.id.text_DriverID);
TextView shipmentIDText = (TextView) findViewById(R.id.text_ShipmentID);
TextView freightShipment = (TextView) findViewById(R.id.text_FreightShipment);
new RetrieveFeedTask(driverIDText.getText.toString(),
shipmentIDText.getText().toString(),
freightShipment.getText().toString()
).execute();
}
class RetrieveFeedTask extends AsyncTask<String, String, Void> {
private String driverIDText, shipmentIDText, freightShipment;
RetrieveFeedTask(String driverIDText, String shipmentIDText, String freightShipment) {
this.driverIDText = driverIDText;
this.shipmentIDText = shipmentIDText;
this.freightShipment = freightShipment;
}
protected Void doInBackground(String... urls) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("DriverID", driverIDText);
request.addProperty("ShipmentID", shipmentIDText);
request.addProperty("FreightShipment", freightShipment);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
if (result != null) {
// HERE IS PROBLEM IN SETTEXT()
driverIDText.setText(result.getProperty(0).toString());
} else {
Toast.makeText(getApplicationContext(), "Login Failed!", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
:super.onPostExecute(テキスト);そのエラーを返す: –
あなたのコードをチェックしてください "クラスRetrieveFeedTask AsyncTask" –
それはString、String、Stringでなければなりません、このhttps://developer.android.com/reference/android/を読んでください。 os/AsyncTask.html –