Android Tutorial

(avery) #1

By : Ketan Bhimani


324 

Notice that the _id column as well as the expected name and type
columns appears in the query. This is required for the adapter and
ListView to work properly.

Using a ListView instead of a custom user interface enables us to
take advantage of the ListView control’s built-in features, such as
scrolling when the list becomes longer, and the ability to provide
context menus as needed. The _id column is used as the unique
identifier for each ListView child node. If we choose a specific item
on the list, we can act on it using this identifier, for example, to
delete the item.

The PetTracker2 application: Pet Listing Screen ListView
(left) with Delete feature (right).

Now we re-implement the Delete functionality by listening for
onItemClick() events and providing a Delete Confirmation dialog
(right):
Free download pdf