title: Select gender in android like radioButton
body: <p>I'm making a simple program where I want to be able to select my gender much like a radio-button behaviour, you either check female or male, and the other choice is supposed to be unchecked. I have separate images for the buttons, both pressed and not pressed. </p>
  
  <p>I've stored the states in a selector file:</p>
  
  <p><strong>button_female.xml</strong> :</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item android:state_focused="true" android:drawable="@drawable/gender_f"/&gt;
  &lt;item android:state_pressed="true" android:drawable="@drawable/gender_f" /&gt;
  &lt;item android:drawable="@drawable/gender_f_notpressed" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>And in <strong>layout/settings_activity.xml</strong> :</p>
  
  <pre><code>    &lt;Button
          android:layout_width="130dp"
          android:layout_height="130dp"
          android:id="@+id/maleButton"
          android:layout_alignParentTop="true"
          android:layout_marginTop="80dp"
          android:layout_marginLeft="220dp"
          android:drawable="@drawable/button_male"
          android:onClick="onGenderButtonClicked"
          /&gt;
  </code></pre>
  
  <p>And in the activity, the onClick is written as</p>
  
  <pre><code>   public void onGenderButtonClicked(View view) {
          if(feButton.isPressed()){
              maButton.setEnabled(false);
              radioPressed = true;
          } else if (maButton.isPressed()){
              feButton.setEnabled(false);
              radioPressed = true;
          } else {
              radioPressed = false;
          }
  
      }
  </code></pre>
  
  <p>However, this doesn't work for several reasons..</p>
  
  <p><strong>1</strong> : The pictures on the buttons don't show up, either pressed or unpressed. </p>
  
  <p><strong>2</strong> : My code is <em>bad</em>, the buttons don't work as expected. I would like to have them behave as a radio group (you either choose male or female as your gender).. </p>
  
  <p>So I seem to have two problems here. Does anyone know a good way to solve this? I'm very new to writing android apps..</p>