Xml_ parsing--httputils

Source: Internet
Author: User

@XStreamAlias ("oschina")publicclass  mydatas {  Publicclass  mynewslist {    @XStreamImplicit (itemfieldname="news " )    private list<mynews> news;

Package Com.example.fragment;import Java.text.simpledateformat;import java.util.arraylist;import Java.util.date;import Java.util.list;import Com.example.adapter.copyofmybaseadpter;import Com.example.adapter.mybaseadpter;import Com.example.bean.mmsupper;import Com.example.bean.myblog;import Com.example.view.xlistview;import Com.example.view.xlistview.ixlistviewlistener;import com.example.vo.Mynews; Import Com.example.vo.super;import Com.example.yk06.r;import Com.lidroid.xutils.httputils;import Com.lidroid.xutils.exception.httpexception;import Com.lidroid.xutils.http.responseinfo;import Com.lidroid.xutils.http.callback.requestcallback;import Com.lidroid.xutils.http.client.HttpRequest.HttpMethod; Import Com.thoughtworks.xstream.xstream;import Android.os.bundle;import Android.support.v4.app.fragment;import Android.view.layoutinflater;import Android.view.view;import Android.view.ViewGroup; Public classF1 extends Fragment implements ixlistviewlistener{PrivateXlistview ListView; String URL;intmm;PrivateMybaseadpter Mybaseadpter;PrivateCopyofmybaseadpter Mybaseadpte;intCount=1;PrivateList<mynews> l=NewArraylist<mynews>();PrivateList<myblog> li=NewArraylist<myblog>(); PublicF1 (String URL,intmm) {super ();  This. url =URL;  This. mm =mm;} @Override PublicView Oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {View view< /c0>=inflater.inflate (R.LAYOUT.ACTIVITY_F1,NULL); ListView=(Xlistview) View.findviewbyid (R.id.lsitview); Listview.setpullloadenable (true); Listview.setpullrefreshenable (true); Listview.setxlistviewlistener ( This);                Init (); returnview; }Private voidinit () {//TODO auto-generated Method StubHttputils utils=Newhttputils (); Utils.send (httpmethod.get, url+count++,NewRequestcallback<string>() {@Override Public voidonfailure (HttpException arg0, String arg1) {//TODO auto-generated Method Stub} @Override Public voidOnsuccess (responseinfo<string>arg0) {            //TODO auto-generated Method StubString ss=Arg0.result; XStream Stream=NewXStream (); if(mm==0|| mm==1) {stream.processannotations (Super.class); Super Super1=(Super) stream.fromxml (ss); List<Mynews> ll=super1.getnewslist (). Getnews (); L.addall (0, LL); Mybaseadpter=NewMybaseadpter (L, getactivity ());            Listview.setadapter (Mybaseadpter); }            if(mm==2|| mm==3) {stream.processannotations (mmsupper.class); Mmsupper Super1=(Mmsupper) stream.fromxml (ss); List<Myblog> ll=super1.getblogs (). Getblog (); Li.addall (0, LL); System. out. println (Li.tostring ()); Mybaseadpte=NewCopyofmybaseadpter (Li, Getactivity ());            Listview.setadapter (MYBASEADPTE); }        }    });}Private voidonLoad () {//TODO auto-generated Method StubListview.stoprefresh ();    Listview.stoploadmore (); //Set Date formatSimpleDateFormat DF =NewSimpleDateFormat ("YYYY-MM-DD HH:mm:ss"); //get current system timeString nowtime = Df.format (NewDate (System.currenttimemillis ())); //the current time when the prompt is refreshed when it is releasedListview.setrefreshtime (nowtime);} @Override Public voidOnrefresh () {//TODO auto-generated Method Stubinit (); OnLoad ();} @Override Public voidOnloadmore () {//TODO auto-generated Method StubHttputils utils=Newhttputils (); Utils.send (httpmethod.get, url+count++,NewRequestcallback<string>() {@Override Public voidonfailure (HttpException arg0, String arg1) {//TODO auto-generated Method Stub} @Override Public voidOnsuccess (responseinfo<string>arg0) {            //TODO auto-generated Method StubString ss=Arg0.result; XStream Stream=NewXStream (); if(mm==0|| mm==1) {stream.processannotations (Super.class); Super Super1=(Super) stream.fromxml (ss); List<Mynews> ll=super1.getnewslist (). Getnews ();            L.addall (LL);                        Mybaseadpter.notifydatasetchanged (); }            if(mm==2|| mm==3) {stream.processannotations (mmsupper.class); Mmsupper Super1=(Mmsupper) stream.fromxml (ss); List<Myblog> ll=super1.getblogs (). Getblog ();                Li.addall (LL);            Mybaseadpte.notifydatasetchanged ();    }        }    }); OnLoad ();}}

Xml_ parsing--httputils

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.