Question

I have a listview where I show the users some titles and they can access these titles to view the content or they can add this title as favorite to read it later; How can I do this favorite button I tried to take the button and if it's favorite or not from the database but can't figure out how I can do it... Is there a tutorial or something...

What I've done is :

SimpleCursorAdapter adapter =new SimpleCursorAdapter(this,R.layout.rating,cu,new String[]{"Title", "Favorites"}, new int[]{R.id.text1, R.id.bt_rating},CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

where title is getting the titles to place in the textview text1 and the favorites is getting true or false to place in an attribute of the button so that if it's true the button(which is a star) should be on, if it's false it should be off.. but here it's taking the text and placing it in the text of the button so I am getting a button where it's written on false or y(for true); how can I fix this?

thanks.

Was it helpful?

Solution

You need to custom adapter in listview, and in adapter layout, put checkbox to implement favorites.

Change your checkbox image to favorite image, and set oncheckedchangelistener to set your database.

This is a tutorial for simple multiple selection checkboxes listview.

OTHER TIPS

You can look into maintaining checkbox states in a listview.

Then after looking into it , add a checkbox and whatever title you want to read later, just check the correspoding checkbox and store that title in another array list.

Use that array list to create another ListView so you will see only those titles for which checkbox has checked or in other words Your Favorites

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top