-1

I have been trying to use expandable listview to be populated with data from a database, i can display this data in a simple listview (each row for each item on the listview).

However in my app i want to give the option to the user to create groups/lists of items, i will give an example:

FRUITS, i can add fruits individually: apple, watermelon, kiwi, pear.. and then i want to create the group "Red Fruits" that will have "apple" and "water melon" and "Green fruits" that will have "kiwi" and "pear"

I want to be able to chose wich items i want to add to a specifc list and store that list in the database.

I have been searching and so far this is what i got into:

  • I need to create a ArrayList of the fruit object. My doubt: The fruits are already added in the database, how will i add items to this arraylist, by the Ids on the databse ?

  • How to store this list in the satabase ?

  • How to get this ArrayList displayed into a expandable listview ?

1 Answers1

0

Hi the answers

  1. Yes, you need to store your fruits in ArrayList and saving the data. For this, follow the docs.

  2. Create a custom adapter for your ListView, here is a guide. For expandable listview adapter, read the next answer.

  3. This post can be helpful.

Cheers!

noe
  • 794
  • 8
  • 13