Volley使用笔记(二)
2016-06-14 03:11
260 查看
JsonRequest的用法与StringRequest相似。
设置POST参数的方法除了getParams()还有一种
其实可以直接写在构造函数中,添加参数Request.Method.POST,jsonParams
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest("http://m.weather.com.cn/data/101010100.html", null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.d("TAG", response.toString()); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("TAG", error.getMessage(), error); } }); @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> map = new HashMap<String, String>(); map.put("params1", "value1"); map.put("params2", "value2"); return map; }
设置POST参数的方法除了getParams()还有一种
HashMap<String, String> hashMap=new HashMap<String,String>(); hashMap.put("channelId",channelId); hashMap.put("account", account); JSONObject jsonParams =new JSONObject(hashMap); JsonObjectRequest request=new JsonObjectRequest(Request.Method.POST, packUrl, jsonParams ,vif.loadingListener(),vif.errorListener());
其实可以直接写在构造函数中,添加参数Request.Method.POST,jsonParams
相关文章推荐
- [Javascript] Decorators in JavaScript
- easyui的tab加载页面中的form重复提交
- Simplify Path
- [转]回答--python django学的很迷茫怎么办?
- Python dis 模块初步使用
- 【3D计算机图形学】变换矩阵、欧拉角、四元数
- UNITY3D圆形算法
- [数据库] Oracle单表查询总数及百分比和数据横向纵向连接
- EasySwift/EasySwift 最简单,最高效,最时髦的swift开发全套解决方案
- python学习 stackflow社区 python的机器学习库
- kruskal最小生成树(MST)算法
- EasySwift/EasyEmoji ios或者swift匹配判断emoji
- 17_AOP入门准备_Salay案例(利用动态代理)
- LVS-DR模型实现负载均衡
- (八)企业部分之nginx+tomcat+memcached负载均衡集群搭建
- [TypeScript] Generating Definition Files
- (七)企业部分之tomcat
- Openstack组件部署 — Keystone Install & Create service entity and API endpoints
- final的初始化
- LeetCode--No.12--Integer to Roman