Reputation: 1108
I have the following code, as taken from this tutorial: http://developer.android.com/training/volley/simple.html
final TextView mResponse = (TextView) findViewById(R.id.response);
RequestQueue queue = Volley.newRequestQueue(this);
String url = "http://www.example.com/";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
mResponse.setText("Response is: "+ response.substring(0,500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mResponse.setText("That didn't work!");
}
});
However, despite the implementation of the onResponse() method within the anonymous Listener class, Response.Listener is being underlined in red, giving the following error: "'Anonymous class derived from Listener' must either be either be declared abstract or implement abstract method 'onResponse(T)' in 'Listener'". I'm not exactly sure why it isn't seeing that I've done exactly that.
Upvotes: 1
Views: 1993
Reputation: 11
compile 'dev.dworks.libs:volleyplus:+'
compile 'com.android.volley:volley:1.0.0'
This problem comes when you use two libraries. To solve the problem, just remove
compile 'com.android.volley:volley:1.0.0'
Your code will work fine.
Upvotes: 1
Reputation: 2408
Response.Listener is a generic type. You have to specify:
new Response.Listener<String>()
Upvotes: 1