title: void is an invalid type for the variable
body: <p>I am getting this error:</p>
  
  <blockquote>
    <p>void is an invalid type for the variable q1b1</p>
  </blockquote>
  
  <p>When I tried this:</p>
  
  <p><strong>My layout:</strong></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:id="@+id/RelativeLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/background"
      android:orientation="vertical"
      tools:context=".Q1" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="20dp"
          android:layout_marginTop="20dp"
          android:gravity="center"
          android:contentDescription="note"
          android:src="@drawable/note" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:textColor="#ffff"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/imageView1"
          android:layout_alignRight="@+id/imageView1"
          android:layout_below="@+id/imageView1"
          android:onClick="q1b1"
          android:text="Button1" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:textColor="#ffff"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/button1"
          android:layout_alignRight="@+id/button1"
          android:layout_below="@+id/button1"
          android:onClick="q1b2"
          android:text="Button2" /&gt;
  
      &lt;Button
          android:id="@+id/button3"
          android:textColor="#ffff"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/button2"
          android:layout_alignRight="@+id/button2"
          android:layout_below="@+id/button2"
          android:onClick="q1b3"        
          android:text="Button3" /&gt;
  
      &lt;Button
          android:id="@+id/button4"
          android:textColor="#ffff"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/button3"
          android:layout_alignRight="@+id/button3"
          android:layout_below="@+id/button3"
          android:onClick="q1b4"
          android:text="Button4" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>My Class:</strong></p>
  
  <pre><code>package com.usd.quiztest;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.Toast;
  
  public class Q1 extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.q1_screen);
  
          public void q1b1 (View view1)
          {
          Toast.makeText(this, "Right",
          Toast.LENGTH_SHORT).show();
          }
          public void q1b2 (View view2)
          {
          Toast.makeText(this, "Wrong! Try again",
          Toast.LENGTH_SHORT).show();
          }
          public void q1b3 (View view3)
          {
          Toast.makeText(this, "Wrong! Try again",
          Toast.LENGTH_SHORT).show();
          }
          public void q1b4 (View view4)
          {
          Toast.makeText(this, "Wrong! Try again",
          Toast.LENGTH_SHORT).show();
          }
      }
  }
  </code></pre>
  
  <p>I have added <code>android:onClick="q1b1"</code> in the <code>Button</code> to show a <code>Toast</code> message and created a  method called "q1b1" in class, but I am getting this error:</p>
  
  <blockquote>
    <p>void is an invalid type for the variable q1b1</p>
  </blockquote>
  
  <p><strong>I followed this tutorial:</strong></p>
  
  <pre><code>Step 6: Making Your App Interactive
  
  Your UI may be finished, but there’s one final step: letting the user
  know whether they’ve selected the correct answer. The easiest way to
  make buttons ‘tappable’ is by implementing the android:onClick
  property for each button.
  
  We’ll start by adding it to the first button:
  Add for each botton:
  
  android:onClick="onClick2003"
  
  Change the name of the event to match each of the years.
  The name of the onClick method must correspond to a public method
  in the MainActivity.Java file.
  Now we need to specify the behavior that
  “onClick2003″ triggers. 
  A straightforward way of telling the user
  they’ve got the question wrong, is with a toast notification.
  Add the following method to MainActivity.java:
  
  public void onClick2003 (View view)
  {
  Toast.makeText(this, "Wrong! Try again",
  Toast.LENGTH_SHORT).show();
  }
  </code></pre>