0

I'm currently making an app for a forum, I want to add a favorites feature where there is a list of different sections of the forums people can add to their favorites list for quick access to them.

I'm having one slight problem though, I'm using a listview for the list of their favorites, so I need to add a new value to the listview when the user adds a new section to their favorites.

So really all I need to know, is how can I add to my string array for my list view, with a button? Or can I have all the options in the array and then decide witch ones show up according to what the user has chosen?

2 Answers 2

1

You could send an array of string with the current favourites to the list adapter. When more favourites are added, you can add them to the array and call

list.notfiyDataSetChanged();

This will update the list.

Sign up to request clarification or add additional context in comments.

Comments

0

If you have a large enough array to hold all the possible options you can use setVisibleRowCount(int) to change how many are visible based on how many items are currently in the array.

3 Comments

So are you saying that I put all of the options into the array at the start, then I can you setVisibleRowCount(int) inside a bunch of if statements to decide which ones show depending on which options they've picked? And replace int with the strings inside the array?
create a new array and copy it into the list array each time, but use setVisibleRowCount to limit the number of showing options
Sorry I'm not understanding it, I'll play around with it a little and see what I come up with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.