title: Android custom button extends button reuse button.xml
body: <p>Here is my confirm__button.xml</p>
  
  <pre><code>&lt;Button xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/ConfirmButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      style="@style/buttonConfirm"  &gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p>here is my styles.xml</p>
  
  <pre><code>&lt;resources&gt;
       &lt;style name="buttonConfirm" parent="@android:style/Widget.Button"&gt;
          &lt;item name="android:textColor"&gt;#FFFFFF&lt;/item&gt;
          &lt;item name="android:textSize"&gt;15dip&lt;/item&gt;
          &lt;item name="android:background"&gt;@drawable/ok_button_style&lt;/item&gt;
          &lt;item name="android:focusable"&gt;true&lt;/item&gt;
          &lt;item name="android:clickable"&gt;true&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>here is my ok_button_style.xml</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item android:state_pressed="true" &gt;
          &lt;shape&gt;
            &lt;gradient
                android:startColor="#F6974F"
                android:centerColor="#F58A39"
                android:endColor="#F48028"
                android:angle="270" /&gt;
            &lt;stroke
                android:width="1dp"
                android:color="#F37C22" /&gt;
            &lt;corners
                android:radius="6dp" /&gt;
            &lt;padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" /&gt;
          &lt;/shape&gt;
    &lt;/item&gt;
    &lt;item android:state_focused="true" &gt;
          &lt;shape&gt;
            &lt;gradient
                android:startColor="#F6974F"
                android:centerColor="#F58A39"
                android:endColor="#F48028"
                android:angle="270" /&gt;
            &lt;stroke
                android:width="2dp"
                android:color="#F48028" /&gt;
            &lt;corners
                android:radius="6dp" /&gt;
            &lt;padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" /&gt;
          &lt;/shape&gt;
    &lt;/item&gt;
    &lt;item android:state_enabled="true" &gt;
          &lt;shape&gt;
            &lt;gradient
                android:startColor="#F48028"
                android:centerColor="#F58A39"
                android:endColor="#F6974F"
                android:angle="270" /&gt;
            &lt;stroke
                android:width="1dp"
                android:color="#F5812A" /&gt;
            &lt;corners
                android:radius="6dp" /&gt;
            &lt;padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" /&gt;
          &lt;/shape&gt;
    &lt;/item&gt;
      &lt;item android:state_enabled="false" &gt;
          &lt;shape&gt;
            &lt;solid
                android:color="#FFB380" /&gt;
            &lt;stroke
                android:width="1dp"
                android:color="#FFA366" /&gt;
            &lt;corners
                android:radius="6dp" /&gt;
            &lt;padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" /&gt;
          &lt;/shape&gt;
    &lt;/item&gt;
    &lt;item&gt;
        &lt;shape&gt;
            &lt;gradient
                android:startColor="#F48028"
                android:centerColor="#F58A39"
                android:endColor="#F6974F"
                android:angle="270" /&gt;
            &lt;stroke
                android:width="1dp"
                android:color="#F37C22" /&gt;
            &lt;corners
                android:radius="6dp" /&gt;
            &lt;padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" /&gt;
          &lt;/shape&gt;
    &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>TestActivity.java</p>
  
  <pre><code>public class TestActivity extends Activity {
  private Button btnConfirm;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          btnConfirm = (ConfirmButton)findViewById(R.id.confirmButton1);
  
          btnConfirm.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  btnConfirm.setEnabled(false);
              }
          });
      }
  }
  
  public class ConfirmButton extends Button{
  
      public ConfirmButton(Context context) {
          super(context);
      }
  
      public ConfirmButton(Context context, AttributeSet attrs) {
          this(context, attrs, R.layout.confirm__button);
      }
  
      public ConfirmButton(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  }
  </code></pre>
  
  <p>I do not understand why the <code>btnConfirm</code> has no <code>buttonConfirm</code> style.</p>