Thursday, August 25, 2011

[android-developers] Re: how to handle click events for 3x3 image buttons arrays?

Can you create a List<ImageButton> and add a reference onto it for
each of your buttons, then run a loop to assign the onClickListener?
Then within the onClick(View v) figure out which button was pressed
based on the v value and handle it accordingly? I've done this before
when I only want one button selected at any given time out of a large
set using something like this:

private void setActiveBtn(ImageButton btn){

//deactivate all buttons then reactivate the selection
for(int i=0; i < buttonSet.size(); i++){
buttonSet.get(i).setSelected(false);
}
btn.setSelected(true);
}

On Aug 25, 6:47 am, Hitendrasinh Gohil <hitendrasin...@gmail.com>
wrote:
> Hi,
>
> I am having 3x3 array which contains 3x3 imagebuttons array.I am
> repeating 3x3 imagebuttons 9 times.
> how can i handle click events for that?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment