title: While showing a toast in android code, I get the following error: java.lang.RuntimeException: setView must have been called
body: <p>Code I am using:</p>
  
  <pre><code>Toast t = new Toast(this);
  t.makeText(this, "You clicked the button..", Toast.LENGTH_SHORT);
  t.show();
  </code></pre>
  
  <p>[ I know I can use:</p>
  
  <pre><code>Toast t = Toast.makeText(this, "You clicked the button..", Toast.LENGTH_SHORT);
  t.show()
  </code></pre>
  
  <p>but I want to know the problem with the code snippet at the top ]</p>
  
  <p>Detailed Error Log:</p>
  
  <pre><code>12-07 15:09:58.333: E/AndroidRuntime(16159): FATAL EXCEPTION: main
  12-07 15:09:58.333: E/AndroidRuntime(16159): java.lang.IllegalStateException: Could not execute method of the activity
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.view.View$1.onClick(View.java:3838)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.view.View.performClick(View.java:4475)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.view.View$PerformClick.run(View.java:18786)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.os.Handler.handleCallback(Handler.java:730)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.os.Handler.dispatchMessage(Handler.java:92)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.os.Looper.loop(Looper.java:176)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.app.ActivityThread.main(ActivityThread.java:5419)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at java.lang.reflect.Method.invokeNative(Native Method)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at java.lang.reflect.Method.invoke(Method.java:525)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at dalvik.system.NativeStart.main(Native Method)
  12-07 15:09:58.333: E/AndroidRuntime(16159): Caused by: java.lang.reflect.InvocationTargetException
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at java.lang.reflect.Method.invokeNative(Native Method)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at java.lang.reflect.Method.invoke(Method.java:525)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.view.View$1.onClick(View.java:3833)
  12-07 15:09:58.333: E/AndroidRuntime(16159):    ... 11 more
  12-07 15:09:58.333: E/AndroidRuntime(16159): Caused by: java.lang.RuntimeException: setView must have been called
  12-07 15:09:58.333: E/AndroidRuntime(16159):    at android.widget.Toast.show(Toast.java:114)
  </code></pre>