Using Buttons in app to jump to different pages HELP


#1

Hi guys,
So i am new to the android programming world and currently having a problem with creating buttons in an app that jump me to different layouts

firstly I added the class to the manifest like so:
**

</application>

**

Then I created the layout and the class (which is same name as the name on the manifest).
I wired up the button like so:

**
mPageOneButton = (Button) findViewById(R.id.page1);
mPageOneButton.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			Intent i = new Intent(MainActivity.this, pageOne.class);
			startActivity(i);
			
		}
	});

**
So logically the Intent sends this to the os, The os looks for the file name in the manifest then returns the correct form correct??

Well i get this error on the LogCat :frowning:

12-24 10:59:39.837: E/AndroidRuntime(3918): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intenttesting/com.example.intenttesting.pageOne}

I have been on this for a while and still am, back tracking my every step and comparing it to the book example I coded that actually works!

Can anyone be a help?

Merry Christmas all and happy coding!


#2

[quote=“monnmon”]Hi guys,
So i am new to the android programming world and currently having a problem with creating buttons in an app that jump me to different layouts

firstly I added the class to the manifest like so:
**

</application>

**

Then I created the layout and the class (which is same name as the name on the manifest).
I wired up the button like so:

**
mPageOneButton = (Button) findViewById(R.id.page1);
mPageOneButton.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			Intent i = new Intent(MainActivity.this, pageOne.class);
			startActivity(i);
			
		}
	});

**
So logically the Intent sends this to the os, The os looks for the file name in the manifest then returns the correct form correct??

Well i get this error on the LogCat :frowning:

12-24 10:59:39.837: E/AndroidRuntime(3918): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intenttesting/com.example.intenttesting.pageOne}

I have been on this for a while and still am, back tracking my every step and comparing it to the book example I coded that actually works!

Can anyone be a help?

Merry Christmas all and happy coding![/quote]

I’m at the beginner level as well within the Android space. With that said, however, I have not encountered this issue so far. If you don’t mind, could you please paste the entire stack trace?


#3

Sorry for the late reply, studying android and applying it has been so addictive!
The problem with my code before that I found was that I was trying to add ‘android.os’ and ‘android.widget’ values to Variables outside of ‘onCreate’ which would cause Java to wtf is this then sht down the app. Beginner mistake.
If you want message me your email, would love to get to know other beginners as it will make the process more fun and convenient as we might bump into the same problems on this journey :slight_smile:.