title: Cast exception in eclipse designer
body: <p>How to solve exception I get in eclipse designer when placing custom view in another.</p>
  
  <p><code>java.lang.ClassCastException: com.fitness.app.Stopper cannot be cast to android.widget.Button at com.fitness.app.Stopper.&lt;init&gt;(Stopper.java:25).</code></p>
  
  <p>com.fitness.app.Stopper XML:</p>
  
  <pre><code>&lt;merge xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  &lt;Button
      android:id="@+id/btnStartStopper"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="25dp"
      android:text="Start" 
      /&gt;
  
  &lt;Chronometer
      android:id="@+id/chronometer1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignTop="@+id/btnStartStopper"
      android:layout_marginLeft="18dp"
      android:layout_toRightOf="@+id/btnStartStopper"
      android:text="Chronometer"
      android:textSize="45sp" /&gt;
  
  &lt;/merge&gt;
  </code></pre>
  
  <p>and com.fitness.app.Stopper line 25 from an error:
  <code>Button btnStart = (Button) findViewById(R.id.btnStartStopper);</code></p>
  
  <pre><code>    public class Stopper extends LinearLayout {
  
  private Chronometer stopper;
  private boolean stopper_started = false;
  
  public Stopper(Context context)
  {
      super(context);
  }
  
  public Stopper(Context context, AttributeSet attrs) {
      super(context, attrs);
      initializeLayoutBasics(context);        
      this.stopper = (Chronometer) findViewById(R.id.chronometer1);
      Button btnStart = (Button) findViewById(R.id.btnStartStopper);
      btnStart.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              startOrStopStopper(arg0);
          }
      });
  }
  
  private void initializeLayoutBasics(Context context) {
      setOrientation(HORIZONTAL);
      final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      inflater.inflate(R.layout.fragment_stopper, this, true);//TODO change name fragment to different
  }
  
  public void startOrStopStopper(View v)
  {
      if(!stopper_started)
          stopper.start();
      else
          stopper.stop();
  
      stopper_started = !stopper_started;
  }
  </code></pre>
  
  <p>}</p>