First, I would recommend using two different activities rather than just
switching views.  Second, take a look at the logcat output as it will give
you more information about the crash.

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Tue, Mar 23, 2010 at 5:30 AM, Ramji <[email protected]> wrote:

> Hi,
> I just started programmind an application using Eclipse for Android.
> I am creating 2 screens.
>
> 1st screen:
> Has a button which onClick --> takes you to the 2nd screen.
>
> 2nd screen:
> Has a button which onClick -- > takes you to the 1st screen.
>
> just like NEXT and BACK.
>
> But somehow i keep getting "Application Simple application has
> stopped
> unexpectedly." Force Close.
>
>
> My code:Simple.java
>
> package com.sample;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.Button;
>
> public class sample extends Activity {
>    /** Called when the activity is first created. */
>    @Override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.main);
>
>        Button b1 = (Button)findViewById(R.id.button1);
>
>        b1.setOnClickListener(new OnClickListener() {
>                public void onClick(View v)
>                {
>                        setContentView(R.layout.main1);
>
>                        Button b2 = (Button)findViewById(R.id.button2);
>
>                        b2.setOnClickListener(new OnClickListener() {
>                                public void onClick(View v1)
>                                {
>                                        setContentView(R.layout.main);
>                                }
>                        });
>                }
>        });
>    }
> }
>
> Can any once tell what went wrong or what is the best way to do it?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
> To unsubscribe from this group, send email to android-beginners+
> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
> ME" as the subject.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to