Free Android app covering all aspects of addiction, including prevention and treatment

Using Volley to download and display images in a grid

Android Volley GridView Tutorial  grid icon

Here’s the third part of the Volley tutorial.

This is where we show you how to use Volley to download images and display them in a GridView.

Using Volley to download and display images in a list

Android Volley tutorial list icon 

Here’s the second part of the Volley tutorial.

This is where we show you how to use Volley to download images and display them in a ListView.

Using Volley to download, cache and display images in lists and grids

Android Volley Library volley icon

Volley is an HTTP Library that makes networking for Android easy. It’s developed by Google and is free to use in your apps.

This is what Volley can do for you:

  • You can automatically schedule network requests
  • You can have multiple concurrent network connections
  • You can  use disk and memory caches
  • You can prioritise your requests
  • You can cancel your requests
  • You can customize Volley according to your needs
  • Your requests are ordered so its easy to populate your UI with data fetched asynchronously from the network
  • Volley supports the download of strings, images and JSON

Volley is not suitable for large downloads or streaming (Volley holds all responses in memory during parsing so large downloads will use a lot of memory).

You should use the DownloadManager for large downloads.

We’re going to be using Volley to download images for display in a list and grid.

Using the Universal Image Loader to populate a GridView

Universal Image Loader Library UIL Grid icon

The Universal Image Loader or UIL is a Library that you can include in your apps to take care of your images.

The Universal Image Loader Library:

  • Asynchronously downloads and loads your images for you
  • Caches the images in memory and on disk for you
  • Displays the images for you
  • Uses multithreading
  • You can configure it to suite your needs
  • You can set options for each image display
  • It's Free and Open Source

King of the Universe: The Universal Image Loader Library and you

Universal Image Loader Library list icon

So what is the Universal Image Loader Library?

The Universal Image Loader or UIL is a Library that you can include in your apps to take care of your images.

The Universal Image Loader Library:

  • Asynchronously downloads and loads your images for you
  • Caches the images in memory and on disk for you
  • Displays the images for you
  • Uses multithreading
  • You can configure it to suite your needs
  • You can set options for each image display
  • It's Free and Open Source

Using the Picasso Library to load images into a GridView

Android GridView icon

A GridView is a ViewGroup. It lets you show stuff in a two-dimensional grid. You can scroll the grid if there are too many items to fit on the screen.

You can control the look of the grid either dynamically or in xml.

You use a ListAdapter to load the data into the grid.

Working with images can use a lot of memory and can cause your app to hang. Our tutorial will show you how easy it is to use the Picasso Library, which is Open Source and FREE, to efficiently load your images into a grid view.

Using Bitmaps efficiently

Using Images without killing your app

Android Bitmaps picasso list icon

Images take time to download and display. They can make your app unresponsive, especially when using them in list views, grid views and view pagers.

The solution is to download and process them off the main thread. Then resize and cache them for faster loading.

This takes quite a bit of coding, but there’s a simpler solution!

This tutorial will show you how to use the (FREE) Picasso Library to take care of everything for you. You just add one line of code! It couldn’t be easier!

Different images for different devices: it’s all about supply and demand

Android alternative bitmap resources logoThis is the 2nd part of a two part series of articles on designing Android apps for multiple screens. Here's a link to part 1, Different images for different devices: bitmaps, pixels and other things that go bump in the night

Put all images that you use in an Android app inside a drawable folder. You should also supply different size images for the different screen densities.

Alternative bitmaps

Android devices come in different shapes and sizes. Their screen sizes range from small phones to 10 inch tablets and larger TV’s. They also have different screen densities.

Different images for different devices: bitmaps, pixels and other things that go bump in the night

resources icon

Which images to use as image resources

There are two main graphic types, bitmap and vector graphics.

Vector graphics describe an image according to its geometric characteristics and can be resized without losing quality.

In Android, we’re more interested in Bitmap images which are stored electronically as a map of bits.

Another electronic image term is the pixel. Sometimes bits and pixels are interchanged and a bitmap can refer to a map of pixels, where each pixel represents a colour.

Bitmaps are resolution dependent which means they contain a fixed number of pixels so they will lose quality if you change their size.