在实现JsonObjectRequest时,我很难从网络上获得JsonObject。我正在尝试创建一个新的JsonObjectRequest:
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject ratesJsonObj = response.getJSONObject("rates");
String RON = ratesJsonObj.getString("RON");
Log.v("Currency", RON);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});但是所有的一切都是被安卓工作室用红色装饰的,上面写着
Error:(41, 47) error: reference to JsonObjectRequest is ambiguous, both constructor
JsonObjectRequest(int,String,String,Listener<JSONObject>,ErrorListener)
in JsonObjectRequest and constructor
JsonObjectRequest(int,String,JSONObject,Listener<JSONObject>,ErrorListener)
in JsonObjectRequest match有人知道怎么回事吗?
发布于 2016-05-12 11:05:25
试着这样做:
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, (JSONObject) null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject ratesJsonObj = response.getJSONObject("rates");
String RON = ratesJsonObj.getString("RON");
Log.v("Currency", RON);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});发布于 2016-05-12 11:06:02
将null转换为string,它将工作。(字符串)空
https://stackoverflow.com/questions/37184832
复制相似问题