Download to local jar package or import online, jar address: Link: http://pan.baidu.com/s/1gf3VZAb Password: Mmye
//Defining VariablesPrivateRequestqueue mqueue=volley.newrequestqueue (context);//specific method of request
/*
* Parameter 1: request mode, Post,get, etc.
* Parameter 2: Request path
*/Stringrequest stringrequest =NewStringrequest (Request.Method.POST, Networkurl.getrecord,NewResponse.listener<string>() {
/ * JSON string returned after successful request, the string is not encrypted, so bind the object directly * /@Override Public voidOnresponse (String s) {userentity userentity=Newuserentity (); LOG.D ("TAG", s.tostring ()); LOG.E ("Reocrd Home", "Home data record----------:" +s.tostring ()); Try{jsonobject Jo=NewJsonobject (s); /*parsing the outermost data*/String He= Jo.getjsonarray ("Data"). toString (); /*parse directly into a collection of objects*/List<RecordEntity> entities = Json.parsearray (he, recordentity.class); List.clear (); for(recordentity entity:entities) {recordentity recordentity=Newrecordentity (Entity.getid (), Entity.getuid (), Entity.getcontent (), entity.getaddress (), Entity.getfile (), Entity.getfiletype (), entity.getfiled Uration (), Entity.getcategoryid (), Entity.getaddtime (), Entity.getcomments (), Entity.getlikes (), Entity.getlikenum ()); LOG.E ("E", "---------------tiem00000000:" +entity.getaddtime ()); List.add (recordentity); }//Lvlist.notifyall ();adapter =NewRecordadapter (Locationapplication.getcontext (), list); Lvlist.setadapter (adapter); } Catch(jsonexception e) {e.printstacktrace (); } } }, NewResponse.errorlistener () {@Override Public voidOnerrorresponse (Volleyerror volleyerror) {}}) {
/ * Request a parameter to pass * /@OverrideprotectedMap<string, string> getparams ()throwsAuthfailureerror {Map<string, string> map =NewHashmap<string, string>(); Map.put ("id", "1"); returnmap; } }; Mqueue.add (stringrequest);/*Request Data*/ }
Simple use of Android network request volley