Android: Implement favorites in list view

Sapan picture Sapan · May 10, 2011 · Viewed 7.1k times · Source

HI,

My app is about a directory of places where a user can see list of places close to his location and view details of that place.

I want to "add to my favorites" functionality for all the items in list view and detail page view.

What is the best way to do this? I was thinking to do it using CheckBox but was not able to understand how to implement in listview adapter.

I am thinking of the following table straucture for favorites: _id - integer primary key content_identifier - unique identifier for the place (text)

Can someone please help?

Regards, Sapan

Answer

sat picture sat · May 10, 2011

Create a custom listview(check how to create a custom listview and add listeners to it)
and add a checkbox or an image , add a listener(click listener) to the image of the list items, whenever image or checkbox is pressed , add a database entry ( favorites table or so)