Last active
August 29, 2015 14:08
-
-
Save Pierry/be1f3b0ae684a1568ddb to your computer and use it in GitHub Desktop.
Volley Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.android.volley.toolbox.NetworkImageView | |
android:id="@+id/networkImageView" | |
android:layout_width="150dp" | |
android:layout_height="170dp" | |
android:layout_centerHorizontal="true" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ImageView mImageView; | |
String url = "http://i.imgur.com/7spzG.png"; | |
mImageView = (ImageView) findViewById(R.id.myImage); | |
... | |
// Retrieves an image specified by the URL, displays it in the UI. | |
ImageRequest request = new ImageRequest(url, | |
new Response.Listener() { | |
@Override | |
public void onResponse(Bitmap bitmap) { | |
mImageView.setImageBitmap(bitmap); | |
} | |
}, 0, 0, null, | |
new Response.ErrorListener() { | |
public void onErrorResponse(VolleyError error) { | |
mImageView.setImageResource(R.drawable.image_load_error); | |
} | |
}); | |
// Access the RequestQueue through your singleton class. | |
MySingleton.getInstance(this).addToRequestQueue(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment