Using Volley's NetworkImageView and ImageLoader
Our last recipe on Volley will not be a request per se, but a replacement for the ImageView
. Requesting an image to populate an ImageView
is such a common task; Volley combines the functionality to a new view called NetworkImageView
. This recipe will demonstrate how to use a NetworkImageView
.
Getting ready
Create a new project in Android Studio and call it NetworkImageView
. Use the default Phone & Tablet option and select Empty Activity when prompted for Activity Type.
This recipe will be using the setup described in the Getting started with Volley for Internet requests recipe. Follow Steps 1-5 to add Volley to your new project.
How to do it...
With Volley added to your project as described previously, follow these steps:
- Open
activity_main.xml
and replace the existingTextView
with the following XML:<com.android.volley.toolbox.NetworkImageView android:id="@+id/networkImageView" android:layout_width="wrap_content...