发送诠释在HashMap中与排球 [英] Send Int in HashMap with Volley
本文介绍了发送诠释在HashMap中与排球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经实现了这个答案 - http://stackoverflow.com/a/19945676/4281848
在我的code和它的伟大工程,但我目前正在与HashMap中发送一个整数,这是当然的说,它只能发送字符串,我怎么能更改为允许发送整数以及字符串
i have implemented this answer - http://stackoverflow.com/a/19945676/4281848 in my code and it works great, however i am currently trying to send an integer with the hashmap and it is of course saying that it can only send strings, how could i change this to allow sending integers as well as strings
下面是我目前的code
Here is my current code
HashMap<String, Integer> params = new HashMap<String, Integer>();
params.put("uid", userId);
CustomRequest jsObjRequest = new CustomRequest(Request.Method.POST,
jsonUrl,params,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
VolleyLog.v("Response:%n %s", response.toString(4));
int code = response.getInt("code");
String message = response.getString("message");
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsObjRequest, tag_json_obj);
感谢您的任何和所有帮助
Thanks for any and all help
推荐答案
变化:
HashMap<String, Integer> params = new HashMap<String, Integer>();
params.put("uid", userId);
到
HashMap<String, String> params = new HashMap<String, String>();
params.put("uid", String.valueOf(userId));
这篇关于发送诠释在HashMap中与排球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文