我使用mcxiaoke/android-volley library.Im将编译错误作为
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) {
}
});发布于 2015-03-17 17:11:49
将null转换为string或JSONObject,我认为它应该工作得很好。
new JsonObjectRequest(Request.Method.GET,
getRequestUrl(10),
(String)null,
new Response.Listener<JSONObject>()发布于 2015-03-17 17:12:07
比尔·盖茨说得对,如果您在其中一个构造函数中传递null而不是String或JSONObject类型的对象,则该类无法知道使用哪个构造函数。否则,您将得到这个不明确的错误,即构造函数有2个匹配。
尝试:
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,
getRequestUrl(10),
"",
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});发布于 2016-02-02 11:25:32
您刚刚使用了空引用。
new JsonObjectRequest(Request.Method.GET,
getRequestUrl(10),
(String)null,
new Response.Listener<JSONObject>()它对我来说很有用
https://stackoverflow.com/questions/29105222
复制相似问题