Hey guys,

I'm having a very basic problem. I'm trying to switch to a new screen
from the main layout. I have an about button and an about.xml layout I
want people to see when they click the button. So I wrote the code:

Button aboutButton = (Button) findViewById(R.id.about);

aboutButton.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                setContentView(R.layout.about);

                        }

This works fine and when I click the button it goes to that layout.
However when I want to go back to main layout with a menu button and I
write the code:

Button menuButton = (Button) findViewById(R.id.menu);

menuButton.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                setContentView(R.layout.main);

                        }

The problem is this: When I write this code in eclipse I get no errors
and it lets me run it but, I get an error saying the app has stopped
unexpectedly and had to close. Please try again. When I comment out
the code for the listener my app runs again.

Can anybody explain to me why this is happening or can tell me what I
need to do different? Thank you for your help guys.

Sincerely,
Brian Jones

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to