Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old October 27th, 2010, 12:38 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Oct 2010
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default Change Activity via Options Menu

Hi All,

I'm really new to Android development, so I have one basic question.
I have the following code. I want to change the screen(the Activity) via Options menu:
Code:
@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId())
		{
		case R.id.item01:
			Intent intentItem1 = new Intent(this, Item1Activity.class);
			startActivityForResult(intentItem1, 0);
			//startActivity(intentItem1);
			return true;
			
		default: return super.onOptionsItemSelected(item);
		}
		
	}
But the activity doesn't change and the error message I receive while debugging is that "The resource doesn't exist"

Any ideas?

Thanks in advance.

Advertisements
gorjan is offline  
Reply With Quote
sponsored links
Old October 27th, 2010, 06:18 PM   #2 (permalink)
Junior Member
 
Join Date: Oct 2010
Posts: 17
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 1 Time in 1 Post
Default

Your code for changing the activity looks solid.

If you receive the error that a resource cannot be found, that means you're accessing a xml resource that just isn't there. In your example, the only line where you access a resource is your
Code:
case R.id.item01:
line. You should check if your menuitem is really spelled that way.

Besides, your compiler should tell you exactly where and what is causing the error, just check the logcat output.
sscAndroid is offline  
Reply With Quote
Reply
Tags
activity, options menu


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 01:11 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.