1
我在全局添加Row_Cursor_Adapter並在Service_ivr AsyncTask中添加onPostExecute()方法後進行了更改。這是更新的代碼。在AsyncTAsk的setAdapter上出現錯誤?
class Service_ivr extends AsyncTask<String, Void, String>
{
@Override
protected String doInBackground(String... param)
{
SoapObject request = new SoapObject(NAMESPACE ,METHOD_NAME);
request.addProperty("user_id",param[0]);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut=request;
envelope.dotNet =true;
envelope.setOutputSoapObject(request);
try
{
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject obj2 = (SoapObject)envelope.getResponse();
int count = obj2.getPropertyCount();
index = count/7;
final lead_content_IVR [] total_ivr_data = new lead_content_IVR[index];
for(int i=0; i<index ;i++)
{
String call_duration;
String lead_id = obj2.getPropertyAsString(i*7+0);
String lead_call_from = obj2.getPropertyAsString(i*7+1);
String lead_call_to = obj2.getPropertyAsString(i*7+2);
String lead_date=obj2.getPropertyAsString(i*7+3);
String lead_audio=obj2.getPropertyAsString(i*7+4);
String assign_id = obj2.getPropertyAsString(i*7+5);
String time = obj2.getPropertyAsString(i*7+6);
if(lead_call_from.equals("Welcome Sound") || lead_call_from.equals("Call Missed") || lead_call_from.equals("User Disconnected") || lead_call_from.equals("Customer Missed"))
{
call_duration= "5 sec";
}
else
{
call_duration = time.toString().concat(" sec");
}
total_ivr_data[i] = new lead_content_IVR(lead_id,lead_call_from,lead_call_to,lead_date,lead_audio,assign_id,call_duration);
}
adapter = new RowCursorAdapter_IVR(Activity_IVR_Lead.this, R.layout.listview_layout_ivr,total_ivr_data);
}catch(Exception e)
{
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
listView.setAdapter(adapter);
}
}
由於你建議我更新代碼,但錯誤始終是一樣的。
移動'listView.setAdapter(適配器);'onPostExecute方法 –
感謝快速反應內線... – Manish
無法解析符號 – Manish