title: Trying to change button background with a if statement
body: <p>Trying to create a game that kids chase the marble.  I want to have the buttons background change only if another buttons background equal something. But can't get the onclick with the a if statement to work. Here is the code I currently have.</p>
  
  <pre><code>package test.tablet.design;
  
  import java.text.DateFormat;
  import java.util.Date;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class MarbleGame extends Activity {
  
  private Button btnA1mc; private Button btnA2mc; private Button btnA3mc; private Button btnA4mc; private Button btnB1mc; private Button btnB2mc; private Button btnB3mc; private Button btnB4mc;
  private Button btnC1mc; private Button btnC2mc; private Button btnC3mc; private Button btnC4mc; private Button btnD1mc; private Button btnD2mc; private Button btnD3mc; private Button btnD4mc;
  private Button btnE1mc; private Button btnE2mc; private Button btnE3mc; private Button btnE4mc; private Button btnF1mc; private Button btnF2mc; private Button btnF3mc; private Button btnF4mc;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.marble_chase);
      TextView tv_time = (TextView) findViewById(R.id.tv_time);
      String currenttime = DateFormat.getDateTimeInstance().format(new Date());
      tv_time.setText(currenttime);
  
      btnA1mc = (Button)findViewById(R.id.btnA1mc); btnA2mc = (Button)findViewById(R.id.btnA2mc); btnA3mc = (Button)findViewById(R.id.btnA3mc); btnA4mc = (Button)findViewById(R.id.btnA4mc);
      btnB1mc = (Button)findViewById(R.id.btnB1mc); btnB2mc = (Button)findViewById(R.id.btnB2mc); btnB3mc = (Button)findViewById(R.id.btnB3mc); btnB4mc = (Button)findViewById(R.id.btnB4mc);
      btnC1mc = (Button)findViewById(R.id.btnC1mc); btnC2mc = (Button)findViewById(R.id.btnC2mc); btnC3mc = (Button)findViewById(R.id.btnC3mc); btnC4mc = (Button)findViewById(R.id.btnC4mc);
      btnD1mc = (Button)findViewById(R.id.btnD1mc); btnD2mc = (Button)findViewById(R.id.btnD2mc); btnD3mc = (Button)findViewById(R.id.btnD3mc); btnD4mc = (Button)findViewById(R.id.btnD4mc);
      btnE1mc = (Button)findViewById(R.id.btnE1mc); btnE2mc = (Button)findViewById(R.id.btnE2mc); btnE3mc = (Button)findViewById(R.id.btnE3mc); btnE4mc = (Button)findViewById(R.id.btnE4mc);
      btnF1mc = (Button)findViewById(R.id.btnF1mc); btnF2mc = (Button)findViewById(R.id.btnF2mc); btnF3mc =    (Button)findViewById(R.id.btnF3mc); btnF4mc = (Button)findViewById(R.id.btnF4mc);
  
      btnE2mc.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                btnE2mc.setBackgroundResource(R.drawable.marble_x);
                btnB4mc.setBackgroundResource(R.drawable.marble);
            }
        });
      btnB4mc.setOnClickListener(new OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              if (btnE2mc.equals(getResources().getDrawable(R.drawable.marble_x)))
              {
              btnB4mc.setBackgroundResource(R.drawable.marble_x);
              btnC1mc.setBackgroundResource(R.drawable.marble);
              }
              else{}
          }
      });
      btnC1mc.setOnClickListener(new OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              if (btnB4mc.equals(getResources().getDrawable(R.drawable.marble_x)))
              {
              btnC1mc.setBackgroundResource(R.drawable.marble_x);
              btnF1mc.setBackgroundResource(R.drawable.marble);
              }
              else{}
          }
      });
  }
  
  }
  </code></pre>