Hi,

Please call setContentView(R.layout.search);  before using any view.

It should look like this:

   public void onCreate(Bundle icicle)
   {
      super.onCreate(icicle);
      setContentView(R.layout.search);

      searchButton = (Button) findViewById(R.id.ok);
      cancelButton = (Button) findViewById(R.id.cancel);

      searchButton.setOnClickListener(new clicker());
      cancelButton.setOnClickListener(new clicker());

   }

Hsun-Cheng Hu

On 6月28日, 上午4時22分, MichaMicha <[EMAIL PROTECTED]> wrote:
> Hello,
> I'm kinda new to Android, but got some Java experience, but still got
> this annoying error even before i see anything on the screen:
>
> ERROR/AndroidRuntime(1593): Uncaught handler: thread Main exiting due
> to uncaught exception
> ERROR/AndroidRuntime(1593): java.lang.RuntimeException: Unable to
> start activity ComponentInfo{nl.michamicha.android.androidtides/
> nl.michamicha.android.androidtides.androidtides}:
> java.lang.NullPointerException
> ERROR/AndroidRuntime(1593):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 1758)
>
> (...)
>
> ERROR/AndroidRuntime(1593): Caused by: java.lang.NullPointerException
> ERROR/AndroidRuntime(1593):     at
> nl.michamicha.android.androidtides.androidtides.onCreate(androidtides.java:
> 22)
> ERROR/AndroidRuntime(1593):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 847)
> ERROR/AndroidRuntime(1593):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 1728)
> ERROR/AndroidRuntime(1593):     ... 11 more
>
> This is my code:
>
> package nl.michamicha.android.androidtides;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.view.View;
> import android.widget.Button;
>
> public class androidtides extends Activity
> {
>
>    Button searchButton, cancelButton;
>
>    /** Called when the activity is first created. */
>    @Override
>    public void onCreate(Bundle icicle)
>    {
>       super.onCreate(icicle);
>
>       searchButton = (Button) findViewById(R.id.ok);
>       cancelButton = (Button) findViewById(R.id.cancel);
>
>       searchButton.setOnClickListener(new clicker());
>       cancelButton.setOnClickListener(new clicker());
>
>       setContentView(R.layout.search);
>    }
>
>    // -----------------------------------
>
>    class clicker implements Button.OnClickListener
>    {
>       public void onClick(View v)
>       {
>          if (v == searchButton)
>          {
>
>          }
>          if (v == cancelButton)
>          {
>
>          }
>       }
>
>    }
>
> }
>
> Can anyone help me with this problem??

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to