title: How to set background of selected/unselected Button in the XML file
body: <p>I have custom buttons that are supposed to have different backgrounds depending if they are selected or not selected. I want to know if there is a way to state this in the XML file. I have a button for Celsius and a button for Fahrenheit. I want it to work where if one is selected, it stays "pressed" and unable to be clicked, while the other button can be pressed.</p>
  
  <pre><code>        &lt;Button
              android:id="@+id/celsiusButton"
              android:text="C"
              android:background="@drawable/button_unpressed_shape"
              android:layout_weight="3"
              android:layout_height="match_parent"
              android:layout_width="0dip"
              android:gravity="center" /&gt;
  
          &lt;Button
              android:id="@+id/fahrenheitButton"
              android:text="F"
              android:background="@drawable/button_unpressed_shape"
              android:layout_weight="3"
              android:layout_height="match_parent"
              android:layout_width="0dip"
              android:gravity="center" /&gt;
  </code></pre>
  
  <p>The Celsius button is defaulted to selected. I try working on it like this in my code, but it just seems to messy:</p>
  
  <pre><code>    tempText = (TextView) findViewById( R.id.temperatureId );
      celsiusButton = (Button) findViewById( R.id.celsiusButton );
      celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
      celsiusButton.setClickable( false );
  
      celsiusButton.setOnClickListener( new OnClickListener() {
          public void onClick(View v) {
              if( hasRead ) {
                      celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
                      celsiusButton.setClickable( false );
                      fahrenheitButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_unpressed_shape ) );
                      fahrenheitButton.setClickable( true );
                      temperature = ( ( ( temperature - 32 ) * 5 ) / 9 );
                      tempText.setText( Double.toString( temperature ).substring( 0, ( Double.toString( temperature ).length() - 2 ) ) + " C" );
              }
          }       
      });
  
      fahrenheitButton = (Button) findViewById( R.id.fahrenheitButton );
      fahrenheitButton.setOnClickListener( new OnClickListener() {
          public void onClick( View v ) {
              if( hasRead ) {
                  fahrenheitButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
                  celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_unpressed_shape ) );
                  celsiusButton.setClickable( true );
                  fahrenheitButton.setClickable( false );
                  temperature = ( ( temperature * 9 ) / 5 ) + 32;
                  tempText.setText( Double.toString( temperature ).substring( 0, ( Double.toString( temperature ).length() - 2 ) ) + "° F" );
              }
          }
      });
  </code></pre>