我想從我的SoapObject.I檢索字符串列表檢索字符串列表正在使用KSoap2打電話給我的web服務返回Strings.Here的名單是我的代碼從Web服務在android系統
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
能
人幫助我從SoapPrimitive對象中獲取所有列表元素。
like List abc =response.getList() or something
??
我想從我的SoapObject.I檢索字符串列表檢索字符串列表正在使用KSoap2打電話給我的web服務返回Strings.Here的名單是我的代碼從Web服務在android系統
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
能
人幫助我從SoapPrimitive對象中獲取所有列表元素。
like List abc =response.getList() or something
??
你的情況是這樣的情況下的一個簡化版本:Parsing kSoap response to array of objects
但有微小的差別,你的目標很簡單:
SoapObject result = (SoapObject) envelope.getResponse();
SoapObject soapresults = (SoapObject)result.getProperty(0);
int count = soapresults.getPropertyCount();
ArrayList<PT> simplifiedList = new ArrayList<PT>();
for (int i = 0; i < count; i++)
{
soapresults.getPropertyAs(PT)(i)
}
最後得到的答案與@Thunder的建議 幫助而不是
SoapObject result =(SoapObject)envelope.getResponse(); 我們必須使用
java.util.Vector<String> result11 = (java.util.Vector<String>)envelope.getResponse(); // to get List of Strings from the SoapObject.. then
ArrayList<String> prjList = new ArrayList<String>();
for(String cs : result11)
{
prjList.add(cs);
}
你可以得到你的soapObject的字符串是這樣的:
SoapObject resSoap =(SoapObject)envelope.bodyIn;
int count = resSoap.getPropertyCount();
for (int i=0; i<count;i++){
SoapObject so = (SoapObject) resSoap.getProperty(i);
int idxic = so.getPropertyCount();
lst= new String[idxic];
String item;
for (int e=0; e<idxic;e++){
item=so.getProperty(e).toString();
lst[e]=item;
}
}
這是我done..SoapObject結果=(SoapObject)envelope.getResponse(); \t SoapObject soapResult =(SoapObject)result.getProperty(0); \t int count = result.getPropertyCount(); \t prjList = new ArrayList(); \t對(INT I = 0; I <計數;我++) \t { \t \t prjList.add(soapResult.getPropertyAsString(I)); \t} –
zesn
感謝您的回覆@ Thunder-KC Inc ...我嘗試了您的代碼,但在使用此代碼將上述列表元素的值設置爲我的Spinner(Dropdown)時出現以下異常: intent.putStringArrayListExtra (「projectListSpinner」,simlifiedList); 異常 12-04 11:14:01.819:E/AndroidRuntime(552):致命異常:主 12-04 11:14:01.819:E/AndroidRuntime(552):java.lang.RuntimeException:無法啓動活動ComponentInfo {com.nevaeh.emsandroid/com.nevaeh.emsandroid.TourRequest}:java.lang.NullPointerException 12-04 11:14:01.819:E/AndroidRuntime(552): plz幫我先生 – zesn
是這個清單從ksoap中提取的列表? –