Hi kenishant,

When a java file will create , in that case, only one (1) time
setContentView (R.layout.abcd) you can create.
And another case is, there must be some what mismatch with the java file and
the xml file.
so in these cases, NullPointerException can come.

Thanks,
Dolan.

On Sat, Jun 21, 2008 at 4:59 PM, redhatab <[EMAIL PROTECTED]> 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