On Sun, Sep 4, 2011 at 1:44 PM, Zwiebel <[email protected]> wrote:
> I want to make a program, which will has a lot of buttons. If the user
> clicks one button, I want to add a specified number (int) to an array.
>
> int[] array;
>
> array = new int[20];
>
> button.setOnClickListener(new View.OnClickOnListener) {
>
> @Override
>      public void onClick (View v) {
>              //something to add the button's specified number to the
> array
> }
>
> }
>
> What I need to write to the method to add the number to the array? Is
> there a method for this?

You cannot add to a standard Java array (int[]), as the length of
those is fixed. You will need to use something like ArrayList.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.6 Available!

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

Reply via email to