Jason
Jason

Reputation: 125

android adding buttons to gridview

I'm new to android programming. I'm trying to make 2x2 matriks using gridview and each spot has a button..

my questions are :

  1. how to add the buttons ?

  2. How to declare the UI layout ?

  3. how to set the click listener to each button ?

THX for the help

Upvotes: 1

Views: 7240

Answers (1)

source.rar
source.rar

Reputation: 8090

Basically you need to associated an Adapter with your GridView that will keep track of the data/contents of the view. And from the getView() of your Adapter you return the type of View that you want (Button in this case) and handle button selection etc.

Check out the Hello-GridView example for a better undersatnding

Upvotes: 4

Related Questions