How to wait until second button is pressed?
<p>I have a bunch of buttons, and some terms assigned to them. I want user to connect them by their meaning. Anyway, I need when a user press a button, nothing to happen, just maybe to set a color to it, and wait until he press another one, and then to take some action(in my case to compare the terms in setText of the buttons). Again, when he press next button nothing to happen until he press 4th button and so on. How can I do that? I've done all the job until this part, I've imported database, assign text to my buttons and so on.</p>

<p>EDIT:</p>

<p>OK, here it is like Stephan asked. I use one onClickListener for all buttons. I assigned them a tag (correct I hope...I used same tags for correct pairs), I will use it later to check for correct answer (still learing that). I set the button to change it's color when pressed, and now I need it to wait until I press some other button from ArrayList labelB. If I press a button from labelA group of buttons, I want nothing to happen, only to change color. Maybe you guys think "wow this is so simple and lame" but it's pretty much complicated for me now. :)</p>

<pre><code>public class Game extends Activity implements View.OnClickListener{


    // labelForButton and tagForButton
       class MyStruct {
       public MyStruct (String lab, String t){
        label = lab;
        tag = t;
    }
       private String label;
       private String tag;
       }

       final OnClickListener clickListener = new OnClickListener() {
        public void onClick(View v) {

         Button button = (Button)v;
         button.setBackgroundColor(Color.YELLOW);

            }
     };

Button a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5,b6,b7,b8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.game);


a1 = (Button) findViewById(R.id.bA1);
        a2 = (Button) findViewById(R.id.bA2);
        a3 = (Button) findViewById(R.id.bA3);
        a4 = (Button) findViewById(R.id.bA4);
        a5 = (Button) findViewById(R.id.bA5);
        a6 = (Button) findViewById(R.id.bA6);
        a7 = (Button) findViewById(R.id.bA7);
        a8 = (Button) findViewById(R.id.bA8);
        b1 = (Button) findViewById(R.id.bB1);
        b2 = (Button) findViewById(R.id.bB2);
        b3 = (Button) findViewById(R.id.bB3);
        b4 = (Button) findViewById(R.id.bB4);
        b5 = (Button) findViewById(R.id.bB5);
        b6 = (Button) findViewById(R.id.bB6);
        b7 = (Button) findViewById(R.id.bB7);
        b8 = (Button) findViewById(R.id.bB8);

nextQuestion();
}

public void nextQuestion() {

        TestAdapter mDbHelper = new TestAdapter(this);
        mDbHelper.createDatabase();

        try{

            mDbHelper.open(); 

            Cursor c = mDbHelper.getTestData(generateWhereClause());

            mAnsweredQuestions.add(c.getLong(0));

            ArrayList&lt;MyStruct&gt; labelsA = new ArrayList&lt;MyStruct&gt;();
            ArrayList&lt;MyStruct&gt; labelsB = new ArrayList&lt;MyStruct&gt;();

            labelsA.add(new MyStruct(c.getString(2), "1"));
            labelsB.add(new MyStruct(c.getString(3), "1"));
            labelsA.add(new MyStruct(c.getString(4), "2"));
            labelsB.add(new MyStruct(c.getString(5), "2"));
            labelsA.add(new MyStruct(c.getString(6), "3"));
            labelsB.add(new MyStruct(c.getString(7), "3"));
            labelsA.add(new MyStruct(c.getString(8), "4"));
            labelsB.add(new MyStruct(c.getString(9), "4"));
            labelsA.add(new MyStruct(c.getString(10), "5"));
            labelsB.add(new MyStruct(c.getString(11), "5"));
            labelsA.add(new MyStruct(c.getString(12), "6"));
            labelsB.add(new MyStruct(c.getString(13), "6"));
            labelsA.add(new MyStruct(c.getString(14), "7"));
            labelsB.add(new MyStruct(c.getString(15), "7"));
            labelsA.add(new MyStruct(c.getString(16), "8"));
            labelsB.add(new MyStruct(c.getString(17), "8"));

            Collections.shuffle(labelsA);
            Collections.shuffle(labelsB);

            pitanje.setText(c.getString(1));

            a1.setText(labelsA.get(0).label);
            a1.setTag(labelsA.get(0).tag);
            a1.setOnClickListener(clickListener);
            b1.setText(labelsB.get(0).label);
            b1.setTag(labelsB.get(0).tag);
            b1.setOnClickListener(clickListener);
            a2.setText(labelsA.get(1).label);
            a2.setTag(labelsA.get(1).tag);
            a2.setOnClickListener(clickListener);
            b2.setText(labelsB.get(1).label);
            b2.setTag(labelsB.get(1).tag);
            b2.setOnClickListener(clickListener);
            a3.setText(labelsA.get(2).label);
            a3.setTag(labelsA.get(2).tag);
            a3.setOnClickListener(clickListener);
            b3.setText(labelsB.get(2).label);
            b3.setTag(labelsB.get(2).tag);
            b3.setOnClickListener(clickListener);
            a4.setText(labelsA.get(3).label);
            a4.setTag(labelsA.get(3).tag);
            a4.setOnClickListener(clickListener);
            b4.setText(labelsB.get(3).label);
            b4.setTag(labelsB.get(3).tag);
            b4.setOnClickListener(clickListener);
            a5.setText(labelsA.get(4).label);
            a5.setTag(labelsA.get(4).tag);
            a5.setOnClickListener(clickListener);
            b5.setText(labelsB.get(4).label);
            b5.setTag(labelsB.get(4).tag);
            b5.setOnClickListener(clickListener);
            a6.setText(labelsA.get(5).label);
            a6.setTag(labelsA.get(5).tag);
            a6.setOnClickListener(clickListener);
            b6.setText(labelsB.get(5).label);
            b6.setTag(labelsB.get(5).tag);
            b6.setOnClickListener(clickListener);
            a7.setText(labelsA.get(6).label);
            a7.setTag(labelsA.get(6).tag);
            a7.setOnClickListener(clickListener);
            b7.setText(labelsB.get(6).label);
            b7.setTag(labelsB.get(6).tag);
            b7.setOnClickListener(clickListener);
            a8.setText(labelsA.get(7).label);
            a8.setTag(labelsA.get(7).tag);
            a8.setOnClickListener(clickListener);
            b8.setText(labelsB.get(7).label);
            b8.setTag(labelsB.get(7).tag);
            b8.setOnClickListener(clickListener);

        }


        finally{
            mDbHelper.close();
        }
    }
</code></pre>
