Issue with using an image button in Android Studio
<p>I'm creating a Soundboard app which uses buttons currently to make different sounds. However I want to change the buttons to image buttons, having tried this I get the following error:
Unexpected Cast to ImageButton: Layout tag was imageView.
I've tried looking around the internet but can't find a fix. The code in the java class looks like this.</p>

<pre><code> public class SecondActivity extends AppCompatActivity {
    Button b,b2;
    MediaPlayer nice,burp,fancy;
    ImageButton IMG;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        b = (Button) findViewById(R.id.button);
        b2 = (Button) findViewById(R.id.button3);
        nice = MediaPlayer.create(this, R.raw.nice);
        burp = MediaPlayer.create(this, R.raw.burp);
        fancy = MediaPlayer.create(this, R.raw.fancy);
        configureImageButton();

        b.setOnClickListener(new View.OnClickListener() {

                                 public void onClick(View view) {
                                     nice.start();
                                 }


                             }


        );
        b2.setOnClickListener(new View.OnClickListener() {

                                             public void onClick(View view) {
                                                 fancy.start();
                                             }


                                         }

        );
    }

        private void configureImageButton() {
        ImageButton IMG = (ImageButton) findViewById(R.id.IMG);


        IMG.setOnClickListener(new View.OnClickListener() {

                                   public void onClick(View view) {
                                       burp.start();
                                   }


                               }

        );
    }
</code></pre>

<p>The XML code looks like this:</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.oliver.olliessoundofmusic.MainActivity"&gt;

    &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Nice"
        android:id="@+id/button"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true" /&gt;

    &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fancy"
        android:id="@+id/button3"
        android:layout_alignTop="@+id/button"
        android:layout_toEndOf="@+id/button" /&gt;

    &lt;ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/IMG"
        android:background="@drawable/robert"
        android:layout_toEndOf="@+id/button3" /&gt;
    &lt;/RelativeLayout&gt;
</code></pre>

<p>I just want imageButtons to work with action listeners the same way a normal button would, to make the app more visually appealing. </p>

<p>Thanks in advance.</p>