Listener(s) for array of buttons
<p>For my own practice I am a creating an array of 3 buttons in the instance field and i would like all of them to have setOnClickListeners,which allow each button to change the BackGround Color of a text View.Can any person please guide me towards the right direction.Here is my code:     </p>

<pre><code>         public class MainActivity extends Activity {

      Button b = {(Button)findViewById(R.id.button1), 
                  (Button)findViewById(R.id.button2),
                   (Button)findViewById(R.id.button3),};

     TextView tv;

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

    tv = (TextView) findViewById(R.id.textView1);

   for(int i=0; i &lt; b.length;i++){





    b[i].setOnClickListener(new OnClickListener() {

    @Override
        public void onClick(View v) {

            if(butt[0].isPressed()){
        tv.setBackgroundColor(Color.BLACK);
            }


            if(b[1].isPressed()){
                tv.setBackgroundColor(Color.BLUE);
                }
            if(b[2].isPressed()){
                tv.setBackgroundColor(Color.RED);
                }

                }
               });


               }
            }

       }
</code></pre>
