Skip to content Skip to sidebar Skip to footer

How To Parse In Android Application Arraylist From Php Webservice

public static UserFriendListContainer getFriendList(SoapObject wizardobject)//TESTED { UserFriendListContainer container= new UserFriendListContainer(); List&

Solution 1:

publicstatic UserFriendListContainer getfriendlist(SoapObject wizardobject) throws XmlPullParserException, IOException {

        UserFriendListContainer container= newUserFriendListContainer();
        UserFriendListModel model = newUserFriendListModel();

         List<UserFriendListModel> list= null;
          list=newArrayList<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..

Solution 2:

Are you sure that wizardobject.getProperty(i)

returns a SoapObject?? I would try with a String or just debug it without doing the casting and see what kind of object it is.

Check this -> SoapObject documentation

By the way it's handier if you post the error stack trace.

Post a Comment for "How To Parse In Android Application Arraylist From Php Webservice"