Just a tip on NullPointerExceptions:  if you are using eclipse in debug mode 
there is a pane for your Breakpoints.  In this pane there is a button that 
looks like "J!" and it will let you add an exception to your breakpoint list.  
This will cause your app to pause whenever this exception is thrown while 
debugging your app.  This is a good way to determine what may be happening.

Also, the line number will be available if you look at the LogCat output.

-- 

Zach Hobbs
HelloAndroid.com
Android OS news, tutorials, downloads 



On Saturday 21 June 2008 07:29:02 redhatab wrote:
> Hi,
>
> Am a total beginner and I was trying out to extrapolate on the Hello
> Android code, but I've sort of hit a road block with a null pointer
> exception. The code is as below:
>
> public class HelloAndroid extends Activity
> {
>          @Override
>          public void onCreate(Bundle icicle)
>          {
>              super.onCreate(icicle);
>
>              setContentView(R.layout.screen1);
>
>              Button btn = (Button) findViewById(R.id.hellobtn);
>                btn.setOnClickListener(new View.OnClickListener() {
>                    public void onClick(View view) {
>                        setContentView(R.layout.screen2);
>                    }
>                });
>          }
> }
>
> As soon as I run this, the emulator gives me a null pointer exception.
>
> The res/layout/screen1.xml and res/layout/screen2.xml are working
> perfectly fine because when I just run
> setContentView(R.layout.screen1) without the onClickListener, both the
> screens work fine.
>
> I suppose the null pointer exception pops in the onClick function.
>
> Pls help!!
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to