Android image Spinner tutorial

In a flat spin: Showing images in a Spinner

Android Spinner spinners icon

Spinners display a list of selectable items.

When first displayed, the Spinner only shows the currently selected item. Touching the Spinner displays the full list of items that the user can choose from.

Our tutorial will show you how to use a Spinner to display a list of images that the user can choose from.

What! No XML? Creating layouts programmatically

Android layout programmatically code layout icon 

Our tutorial app

Our tutorial app creates a table containing text views, text fields and a button.

There is no XML layout file as we do everything programmatically.

A Toast message displays the input after the user has filled in the text fields and pressed the button.

Using Intents and Intent Filters in your apps: A tutorial

Android Intents and Intent Filters tutorial icon

Our tutorial app shows you how to use intents and intent filters in your apps.

Here’s a quick overview of what we’ll cover. We’ll show you how to:

  • use explicit intents to:
    • start a new activity
    • start an activity to get a result
    • start a service
    • broadcast an intent
    • start a new activity from within a broadcast receiver
  • use implicit intents to:
    • use other app’s components to:
      • send an email
      • pick a contact from the contacts list
      • make a phone call
  • use a pending intent to send a notification
  • use intent filters for:
    • a broadcast receiver
    • an activity

Intents and Intent Filters

Getting to know Intents and Intent Filters

Android Intents and Intent Filters icon

Intents are messages that you can pass around between your app components. You can also send them to components in other apps. This enables you to create powerful applications where you can use other app’s components to perform tasks for you, such as playing music, sending email, and taking pictures.

Here are some of the things that you can do with intents:

  • Start activities
  • Start Services
  • Deliver broadcasts

The Android System also uses intents to signal changes such as low battery, incoming sms messages and phone calls. You can listen for these intent messages in your apps.  You can also use intents to pass data.

All about repeating, I said repeating, Alarms

Android repeat alarm icon

You can use alarms to trigger events at any time even if your app is not running.

Alarms:

  • Enable you to trigger events at set times and/or intervals
  • Can be used together with receivers to start services and other operations
  • Operate outside of your app so they can trigger events even if your app is not running - even if the device is asleep
  • Help you to minimise your app’s resources. Let the alarm take care of it

Device sleeping on the job? Here’s how you can manage the device awake state

Android wakelocks icon 

You can schedule work to be done. Problem is, nothing will happen if the CPU is sleeping!

The solution is to use a wake lock to prevent the CPU from sleeping while it’s doing your work.

You may also want to keep the screen from turning off. Read on and we’ll show you how…

Save time and the environment (just kidding), re-use your layouts

Android Layouts include and merge layouts icon

Don’t duplicate your layouts, use the <include> tag

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.