作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
public static UserFriendListContainer getFriendList(SoapObject wizardobject)//TESTED
{
UserFriendListContainer container= new UserFriendListContainer();
List<UserFriendListModel> list= new ArrayList();
String currobj= wizardobject.getProperty("FriendListResult").toString();
Log.v("CurrentObjet+++++++",currobj.toString());
container.setParserResult(currobj);
SoapObject result = (SoapObject)wizardobject;
for(int i=0;i<result.getPropertyCount();i++)
{
SoapObject object = (SoapObject)wizardobject.getProperty(i);//here it is break
Log.v("result:::::",result.toString());
Log.v("obj:::::",object.toString());
Log.v("friendID",object.getProperty("friendid").toString());
String friendID=object.getProperty("friendid").toString();
Log.v("friendname",object.getProperty("friendname").toString());
String friendname=object.getProperty("friendname").toString();
Log.v("lastaction",object.getProperty("lastaction").toString());
String lastaction=object.getProperty("lastaction").toString();
Log.v("friendphoto",object.getProperty("friendphoto").toString());
String friendphoto=object.getProperty("friendphoto").toString();
UserFriendListModel model=new UserFriendListModel();
model.setfriendID(friendID);
model.setfriendName(friendname);
model.setfriendPhoto(friendphoto);
model.setLastAction(lastaction);
list.add(model);
}
container.setList(list);
return container;
}
}
-----
<message name="FriendListRequest"/>
<message name="FriendListResponse">
<part name="FriendListResult" type="tns:FirendListArray"/>
</message>
我来自 web 服务的 xml 部分是那个。我试图通过解析访问我的 friend 列表。我无法理解..当我调试它时它在“SoapObject object = (SoapObject)wizardobject.getProperty(i)”中崩溃了..我想要知道如何解析我从网络服务中获取的一个列表??提前感谢您的帮助...
最佳答案
public static UserFriendListContainer getfriendlist(SoapObject wizardobject) throws XmlPullParserException, IOException {
UserFriendListContainer container= new UserFriendListContainer();
UserFriendListModel model = new UserFriendListModel();
List<UserFriendListModel> list= null;
list=new ArrayList<UserFriendListModel>();
Vector vector = (Vector) wizardobject.getProperty("FriendListResult");
Log.v("vector+++++++",vector.toString());
System.out.println("vectorsize+++++++"+vector.size());
int count=vector.size();
for (int i = 0; i <count; ++i) {
SoapObject test=(SoapObject)vector.get(i);
Log.v("test+++++++",test.toString());
Log.v("friendid",test.getProperty("friendid").toString());
String friendID=test.getProperty("friendid").toString();
Log.v("friendname",test.getProperty("friendname").toString());
String friendname=test.getProperty("friendname").toString();
Log.v("lastaction",test.getProperty("lastaction").toString());
String lastaction=test.getProperty("lastaction").toString();
Log.v("friendphoto",test.getProperty("friendphoto").toString());
String friendphoto=test.getProperty("friendphoto").toString();
model.setfriendID(friendID);
model.setfriendName(friendname);
model.setfriendPhoto(friendphoto);
model.setLastAction(lastaction);
list.add(model);
}
container.setList(list);
System.out.println("List==="+list);
return container;
}
大家好,经过如此多的努力,我找到了答案。我可以用上面的代码解析我的数组。谢谢你的兴趣。
关于android - 如何从 php webservice 在 android 应用程序 arraylist 中解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10807150/
我是一名优秀的程序员,十分优秀!