Toan Tran Van
Toan Tran Van

Reputation: 759

How to reload Gridview's Items after changing selected item in Spinner

In my application, I have a Spinner which includes list of categories and GridView to show list of

Images according to selected category.

My question is: "How to reload images on GridView after changing category in Spinner?"

Upvotes: 0

Views: 355

Answers (1)

Michael Krause
Michael Krause

Reputation: 4849

From the code that gets the selected category from the Spinner, get your GridView's adapter and then call clear() on it and then addAll(T... items) with the new category items you want to show.

Keep in mind that this assumes you've created the adapter by passing it a mutable List.

If you created the adapter with an immutable List or T[], then you can create a new adapter and set it on the GridView instead.

Upvotes: 2

Related Questions