Search code examples
androidandroid-gridviewsimplecursoradapterandroid-adapter

Creating an Android GridView full of Buttons. Which Adapter?


I need to create a GridView full of Buttons, each labelled with text from a query.

Which Adapter should I use? A ResourceCursorAdapter, a SimpleCursorAdapater or something else?

(SimpleCursorAdpater seems like it would do the job, except I can't work out how to tell it to put the colum values as an attribute of the button, rather than the content.)


Solution

  • If the you're looking to handle the actual click event of the button (and not the actual parent grid item), I would just extend CursorAdapter and write your own custom CursorAdapter. Inflate your own layout containing the button, set the text, and set the click event.