title: android.widget.RelativeLayout cannot be cast to android.widegt.ImageButton
body: <p>Heyy I want to program an instant messenger and i want to use an <code>ImageButton</code> to confirm sending the Message in the Chat. But when i try to use the <code>ImageButton</code> i get following issue:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.secmess.secmess/com.secmess.secmess.Erik_Kartenberg}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.ImageButton
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
              at android.app.ActivityThread.access$900(ActivityThread.java:169)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5476)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.ImageButton
              at com.secmess.secmess.Erik_Kartenberg.onCreate(Erik_Kartenberg.java:23)
              at android.app.Activity.performCreate(Activity.java:5451)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
              at android.app.ActivityThread.access$900(ActivityThread.java:169)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5476)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
              at dalvik.system.NativeStart.main(Native Method)
  10-02 13:50:38.717  16820-16820/? I/Process﹕ Sending signal. PID: 16820 SIG: 9
  </code></pre>
  
  <p>Here the Activity-Code</p>
  
  <pre><code>    package com.secmess.secmess;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.TextView;
  
  public class Erik_Kartenberg extends Activity {
  
      private EditText nachricht;
      private TextView textout;
      private ImageButton sendbutton;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_erik__kartenberg);
  
          sendbutton = (ImageButton) findViewById(R.id.imagebuutonsend);
          sendbutton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  nachricht = (EditText) findViewById(R.id.editTextwithhint);
                  textout = (TextView) findViewById(R.id.textoutviewer);
                  textout.setText(nachricht.getText());
                  nachricht.setText("");
  
              }
          });
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_erik__kartenberg, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }}
  </code></pre>