Thanks, I tried it now. I have a problem, with this: I need to have two arraylists. I declared them. I declared a "mine" arraylist and an "user" arraylist with this code:
ArrayList mine = new ArrayList(); ArrayList user = new ArrayList(); I want to store in these values, what are will be important to contact with the user: I added values to my mine arraylist: mine.add("0"); mine.add("1"); mine.add("0"); I want to add a values to the user named arraylist if the user press a button. So I added this code: user.add("0"); and user.add("1"); to an another button. I added two Log.i("user", user.toString()); line to the buttons so I can follow how the arraylist looks like in the appropriate moments. Then if the user clicks an another button, I want to compare these lists, so I implemented the following code: for (int j = 0; j < user.size(); j++) { for (int k = 0; k < mine.size(); k++) { if (user.get(j) == mine.get(k)) { //start a new activity } If the two arraylists are the same in the order and in values, I want to show a new screen (its name is for example good), and if not I want to show an another( its name is for example lose). But I have a problem. My program is only show my lose screen if the user only clicked the button which add 1 to the arraylists, or if he/she only clicked the button which add 0 to the arraylist. How can I make my program to run as I want? Thanks in advance On szept. 4, 19:56, Zwiebel <hunzwie...@gmail.com> wrote: > OK thanks for the very fast reply. > > So If I use > > ArrayList<int> array; > > array = new ArrayList(20); > > button.setOnClickListener(new View.OnClickOnListener) { > > @Override > public void onClick (View v) { > //something to add the button's specified number to the > array > > } > } > > And I use the add method for add a number to the ArrayList will be > good? And here is the question, that How I can compare them, too? > > Thanks > > On szept. 4, 19:46, Mark Murphy <mmur...@commonsware.com> wrote: > > > > > > > > > On Sun, Sep 4, 2011 at 1:44 PM, Zwiebel <hunzwie...@gmail.com> 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/commonsguyhttp://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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en