respondiendo a los botones dentro de gridview en android

I have created a grid view with buttons inside.

But now the problem is that i don't understand for which click am i suppose to respond? The one on the grid view or the one on the button?

Moreover i have really no idea on how to set click listeners in the custom adapter class that i have created or should i set them in the main class.

I have tried googling but to no use. I would be really really thankful if someone helps me in figuring out this conceptual problem or at least point me towards a good resource. Thanks.

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

Set an onClickListener for each button.

Define these where you are defining your UI. Most of the time this is in your the onCreate método en tu activity.

button1.setOnClickListener( new View.OnClickListener() {
    public void onClick( View v ) {
        // do something
    }
});

button2.setOnClickListener( new View.OnClickListener() {
    public void onClick( View v ) {
        // do something
    }
});

button3.setOnClickListener( new View.OnClickListener() {
    public void onClick( View v ) {
        // do something
    }
});

button4.setOnClickListener( new View.OnClickListener() {
    public void onClick( View v ) {
        // do something
    }
});

Moreover i have really no idea on how to set click listeners in the custom adapter class that i have created or should i set them in the main class.

Can you give more detail about your adapter?

respondido 09 mar '12, 17:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.