Android列表视图:来自Web服务的数组

时间:2014-02-05 19:58:49

标签: java android

我正在尝试从Web服务中的数组填充android中的列表视图我一直收到错误。这是我的代码。在log cat文件中我收到错误:无法打开文件进行阅读。

ListView tv;

public LocationFragment(){}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_location, container, false);
    getView().findViewById(R.id.listView1);


    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);


    HttpTransportSE ht = new HttpTransportSE(URL);
    try {
        ht.call(SOAP_ACTION, envelope);
        View response = (View)envelope.getResponse();
        tv.setEmptyView(response);


    } catch (Exception e) {

    }
    return rootView;
}


}

1 个答案:

答案 0 :(得分:0)

您不应该中断应用程序的主线程,并且在发出Web请求时应该使用AsyncTask