Android Tutorial

(avery) #1

By : Ketan Bhimani


342 

Pet Tracker application: Entry Screen (left, middle) and Pet
Listing Screen (right).

Accessing Images on the Device

Now that you can visualize what adding photos looks like,let’s
break down the steps needed to achieve this feature. The
PetTracker3 application has the same basic structure as our
previous Pet Tracker projects, with several key differences:

 On the Pet Entry screen, you can choose a photo from a Gallery control,
which displays all the images available on the SD card, or simulated SD
card on the emulator, by accessing the MediaStore content provider (left).
 On the Pet Listing screen, each picture is displayed in the ListView control
(right), again using the MediaStore content provider to access specific
images.
 On the Pet Listing screen, each item in the ListView (right) is a custom
layout. The new PetTracker3 sample application provides two methods to
achieve this: by inflating a custom layout XML file, and by generating the
layout programmatically.
 Internally,we extend BaseAdapter on two different occasions to
successfully bind pet data to the ListView and Gallery with our own custom
requirements.
Free download pdf