Metallicraft
Metallicraft

Reputation: 2201

Android gridview clear/refresh contents

I have a gridview that loads when the app loads. The user can click on a button which gets other data to load into the gridview.

  1. I want to clear the gridview before the other data is loaded. I can't figure this out.
  2. I guess fixing #1 will take care of this, but when i DO click on the button to reload the grid, it doesnt refresh the grid. I know it's loading the data into the grid though, and this is the weird part, there just happens to be a search textview on the screen and when i click on that and the keyboard comes up, the new rows are appended to the existing rows in the grid. It's the only time the grid is updated.

Upvotes: 2

Views: 12504

Answers (2)

Alfred Loh
Alfred Loh

Reputation: 87

I tried 1. clear(), try 2. notifychange but none of these work for me.

At last, i do a gridView.clear() before setAdapter then got it right,

cheers.

Upvotes: 0

Pentium10
Pentium10

Reputation: 208012

For clear:

just call clear() on your adapter, that's how you clear the gridview.

Upvotes: 3

Related Questions