title: Selector for a button which changes its background and text color
body: <p>I am having a group of 3 button and want to change the color and text of a particular button when it is clicked and change again back to normal when another button is clicked.</p>
  
  <p>I am using selector for the first time and I am not clear with the states either can any one help me out with this.</p>
  
  <p>here is what I am doing.</p>
  
  <p>these are my 3 buttons</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/lineartab"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"
      android:gravity="center|center_horizontal"
      android:orientation="horizontal"
      android:weightSum="3" &gt;
  
      &lt;Button
          android:id="@+id/allMessagesBT"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:background="@drawable/message_top_btn_selector"
          android:singleLine="false"
          android:text="All \nMessages"
          android:textColor="#7b818b"
          android:textSize="14sp" /&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginBottom="3dp"
          android:layout_marginTop="3dp"
          android:background="@drawable/line" /&gt;
  
      &lt;Button
          android:id="@+id/createNewBT"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:background="@drawable/message_top_btn_selector"
          android:singleLine="false"
          android:text="Create \nNew"
          android:textColor="#7b818b"
          android:textSize="14sp" /&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginBottom="3dp"
          android:layout_marginTop="3dp"
          android:background="@drawable/line" /&gt;
  
      &lt;Button
          android:id="@+id/deleteBT"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:background="@drawable/message_top_btn_selector"
          android:singleLine="false"
          android:text="Delete \nSelected"
          android:textColor="#7b818b"
          android:textSize="14sp" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and here is my selector xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
  &lt;item android:drawable="@drawable/login_edittext" android:state_selected="true"&gt;&lt;/item&gt;
  &lt;item android:drawable="@drawable/btn_accept_normal" android:state_pressed="true&lt;/item&gt;
  &lt;item android:drawable="@drawable/btn_accept_hover"&gt;&lt;/item&gt;
  
   &lt;/selector&gt;
  </code></pre>
  
  <p>i want to do is change the background color once the button is clicked and keep it that way until another button is clicked</p>