【发布时间】:2015-03-17 17:00:01
【问题描述】:
我正在使用 mcxiaoke/android-volley 库。我收到编译错误
Error:(77, 37) 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
这是我的代码。我不知道出了什么问题。任何帮助表示赞赏
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,
getRequestUrl(10),
null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
【问题讨论】:
-
你正在传递一个空值,传递一个字符串或一个 JSONObject
-
我认为空值是可以接受的。
-
是的 null 被接受,但它不知道你正在调用哪个构造函数。将 null 转换为字符串