title: Android Button doesn't change colour on click
body: <p>When I click on a particular button, the button background's colour is suppose to change while the other buttons remain in its default colour. However, upon running the app, the button doesn't change its colour though the rest of the logic in the code works well. I still can't figure out what's wrong. Any help will be greatly appreciated. Thanks.</p>
  
  <pre><code>  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.timer_test);
  
    adult = (Button) findViewById(R.id.btnAdult);
      peer = (Button) findViewById(R.id.btnPeer);
      material = (Button) findViewById(R.id.btnMaterial);
      physical = (Button) findViewById(R.id.btnPhysical);
  
  
      //Set button disabled, when new activity is turned on
  
      flag.setEnabled(false);
      alarm = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
  
      ...
  
  OnClickListener codes :
  
  if (textDemo.getText().toString() == "Record") {
  View.OnClickListener listener = new View.OnClickListener() {
  @Override
    public void onClick(View v) {
  
    if (v.equals(physical)) {
                 // do something
                physical.setText("PHYSICAL ON CLICK WORKS");
                physicalPrompt = "Yes";
                physical.setBackgroundColor(getResources().getColor(R.color.buttonPressed));
                adult.setBackgroundResource(R.drawable.button_selector);
                peer.setBackgroundResource(R.drawable.button_selector);
                material.setBackgroundResource(R.drawable.button_selector);
   }
  
     else if (v.equals(material)) {
                 // do something
                 material.setText("MATERIAL ON CLICK WORKS");
                 materials = "Yes";
                 material.setBackgroundColor(getResources().getColor(R.color.buttonPressed));
                 peer.setBackgroundResource(R.drawable.button_selector);
                  adult.setBackgroundResource(R.drawable.button_selector);
                  physical.setBackgroundResource(R.drawable.button_selector);
    }
  
      else if (v.equals(peer)){
                  peer.setText("PEER ON CLICK WORKS");
                  peers = "Yes";
                  peer.setBackgroundColor(getResources().getColor(R.color.buttonPressed));
                  physical.setBackgroundResource(R.drawable.button_selector);
                  adult.setBackgroundResource(R.drawable.button_selector);
                  material.setBackgroundResource(R.drawable.button_selector);
  
   }
  
      else if (v.equals(adult)){
                   adult.setText("ADULT ON CLICK WORKS");
                   peers = "Yes";
                   peer.setBackgroundColor(getResources().getColor(R.color.buttonPressed));
                   physical.setBackgroundResource(R.drawable.button_selector);
                   adult.setBackgroundResource(R.drawable.button_selector);
                   material.setBackgroundResource(R.drawable.button_selector);
  
   }
  
      else {
                  // do something else
                  textDemo.setText("Error!");
           }
      }
     };
  
     physical.setOnClickListener(listener);
     material.setOnClickListener(listener);
     peer.setOnClickListener(listener);
     adult.setOnClickListener(listener);
     }
    }
   }
  </code></pre>
  
  <p>In value/colors.xml,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
  &lt;color name="buttonNotPressed"&gt;#2196F3&lt;/color&gt;
  &lt;color name="buttonPressed"&gt;#1976D2&lt;/color&gt;
  
  &lt;!--&lt;color name="colorHighlightFAB"&gt;#B6B6B6&lt;/color&gt;--&gt;
  &lt;color name="ColorPrimary"&gt;#E91E63&lt;/color&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>Extra Codes :</p>
  
  <pre><code>public class Timer_Test extends ActionBarActivity {
  
  //Declare widgets
  Button buttonStart, flag, back, timeButton, adult, peer, material, physical;
  TextView timerTextView, tvTest, interval, child, status, id, session,  
  passName, tvStartTime, textDemo;
  </code></pre>