标签:tar return 简单 volley trace request address ica tco
下载到本地jar包或者在线导入,jar地址:链接:http://pan.baidu.com/s/1gf3VZAb 密码:mmye
//定义变量 private RequestQueue mQueue=Volley.newRequestQueue(context); //具体的请求方法
/*
*参数1:请求方式,POST,GET等
*参数2:请求路径
*/ StringRequest stringRequest = new StringRequest(Request.Method.POST, NetWorkUrl.getrecord, new Response.Listener<String>() {
/*请求成功之后返回的json字符串,这里的字符串没有进行加密,所以直接绑定对象*/ @Override public void onResponse(String s) { UserEntity userEntity = new UserEntity(); Log.d("TAG", s.toString()); Log.e("reocrd首页", "首页数据Record----------:" + s.toString()); try { JSONObject jo = new JSONObject(s); /*解析最外层数据*/ String he = jo.getJSONArray("data").toString(); /*直接解析成对象集合*/ List<RecordEntity> entities = JSON.parseArray(he, RecordEntity.class); list.clear(); for (RecordEntity entity : entities) { RecordEntity recordEntity = new RecordEntity( entity.getId(), entity.getUid(), entity.getContent(), entity.getAddress(), entity.getFile(), entity.getFiletype(), entity.getFileduration(), entity.getCategoryid(), entity.getAddtime(), entity.getComments(), entity.getLikes(), entity.getLikenum()); Log.e("e", "---------------tiem00000000:" + entity.getAddtime()); list.add(recordEntity); } // lvList.notifyAll(); adapter = new RecordAdapter(LocationApplication.getContext(), list); lvList.setAdapter(adapter); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { } }) {
/*请求需要传递的参数*/ @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> map = new HashMap<String, String>(); map.put("id", "1"); return map; } }; mQueue.add(stringRequest);/*请求数据*/ }
标签:tar return 简单 volley trace request address ica tco
原文地址:http://www.cnblogs.com/dingxiansen/p/7520622.html