如何从PHP Web服务的Andr​​oid应用程序的ArrayList解析 [英] How to parse in android application arraylist from php webservice

查看:152
本文介绍了如何从PHP Web服务的Andr​​oid应用程序的ArrayList解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 公共静态UserFriendListContainer getFriendList(SoapObject wizardobject)// TESTED
    {
        UserFriendListContainer集装箱=新UserFriendListContainer();
        清单< UserFriendListModel>名单=新的ArrayList();        。字符串currobj = wizardobject.getProperty(FriendListResult)的toString();        Log.v(CurrentObjet +++++++,currobj.toString());
        container.setParserResult(currobj);        SoapObject结果=(SoapObject)wizardobject;
        的for(int i = 0; I< result.getPropertyCount();我++)
        {                SoapObject对象=(SoapObject)wizardobject.getProperty(我); //这里是休息Log.v(结果:::::,result.toString());
                Log.v(物镜:::::,object.toString());
                Log.v(friendID,object.getProperty(friendid)的toString());
                。字符串friendID = object.getProperty(friendid)的toString();                Log.v(FRIENDNAME,object.getProperty(FRIENDNAME)的toString());
                。字符串FRIENDNAME = object.getProperty(FRIENDNAME)的toString();                Log.v(lastaction,object.getProperty(lastaction)的toString());
                。字符串lastaction = object.getProperty(lastaction)的toString();                Log.v(friendphoto,object.getProperty(friendphoto)的toString());
                。字符串friendphoto = object.getProperty(friendphoto)的toString();                UserFriendListModel模式=新UserFriendListModel();
                model.setfriendID(friendID);
                model.setfriendName(FRIENDNAME);
                model.setfriendPhoto(friendphoto);
                model.setLastAction(lastaction);                list.add(模型);
            }
            container.setList(名单);        返回容器中;
    }}-----
<消息名称=FriendListRequest/>
<消息名称=FriendListResponse>
<部分名称=FriendListResultTYPE =TNS:FirendListArray/>
< /消息>

我的XML部分来自web服务是one.Im试图parsing.I访问我的好友列表不可能理解..when IM调试它在SoapObject对象=(SoapObject)wizardobject.getProperty(I)..我想分手知道我怎么可以解析一个列表,我从web服务采取??谢谢你的帮助提前...


解决方案

 公共静态UserFriendListContainer getfriendlist(SoapObject wizardobject)抛出XmlPullParserException,IOException异常{        UserFriendListContainer集装箱=新UserFriendListContainer();
        UserFriendListModel模式=新UserFriendListModel();         清单< UserFriendListModel>名单= NULL;
          名单=新的ArrayList< UserFriendListModel>();
        矢量矢量=(矢量)wizardobject.getProperty(FriendListResult);          Log.v(载体+++++++,与Vector.toString());
          的System.out.println(vectorsize ++++++++ vector.size());          诠释计数= vector.size();
          的for(int i = 0; I<计数; ++ I){        SoapObject测试=(SoapObject)vector.get(ⅰ);
          Log.v(测试+++++++,test.toString());               Log.v(friendid,test.getProperty(friendid)的toString());
                。字符串friendID = test.getProperty(friendid)的toString();                Log.v(FRIENDNAME,test.getProperty(FRIENDNAME)的toString());
                。字符串FRIENDNAME = test.getProperty(FRIENDNAME)的toString();                Log.v(lastaction,test.getProperty(lastaction)的toString());
                字符串lastaction = test.getProperty(lastaction)的toString()。                Log.v(friendphoto,test.getProperty(friendphoto)的toString());
                字符串friendphoto = test.getProperty(friendphoto)的toString()。                model.setfriendID(friendID);
                model.setfriendName(FRIENDNAME);
                model.setfriendPhoto(friendphoto);
                model.setLastAction(lastaction);                list.add(模型);
            }
            container.setList(名单);
            的System.out.println(列出===+清单);
         返回容器中;
    }

大家好,
这么多的努力后,我发现我的answer..I可以分析我的数组上述code..Thank u表示兴趣。

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> 

my xml part from webservice is that one.Im trying to access my friendlist by parsing.I couldnt understand ..when im debugging it broke in "SoapObject object = (SoapObject)wizardobject.getProperty(i)"..I want to know how can i parse one list that i take from webservice??Thank you for your help in advance...

解决方案

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;
    }

Hi guys, After so many effort i have found my answer..I can parse my array with above code..Thank u for interest..

这篇关于如何从PHP Web服务的Andr​​oid应用程序的ArrayList解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆