small medium large xlarge

25 Jan 2013, 20:20
Miller Ridgeway (13 posts)

Hi, I am a bit new to Android programming, so I am looking for some advice. The problem is, I am on section 3.8 in creating the settings menu, I have all but one error worked out. In my eclipse, it says “settings cannot be resolved or is not a field”. I know this means it cannot locate settings, but I don’t know why. My code is as follows

public boolean onOptionsItemSelected(MenuItem item)
		startActivity(new Intent(this, Prefs.class));
		return true;
	return false; 

It gives me an error on the case My settings file is as follows

The settings file above is located in res/xml. However, I had to create the folder, it was not already there. Any help or input would be appreciated, thanks.

26 Jan 2013, 11:35
Gerry Miller (2 posts)

Is this a run time error? If so have you tried looking in the log - see section 3.10 (Debugging)

Also have you use @Override before your method definition?

26 Jan 2013, 17:37
Anthony Shaw (138 posts)

Miller, I think you may have either missed out or mis-typed the menu.xml from section 3.7, in particular the line

item android:id=”@+id/settings”

I think the above line is what generates

28 Jan 2013, 19:59
Miller Ridgeway (13 posts)

Thanks Anthony! I figured this problem out promptly after I posted this, but did not have access to internet. Regardless, thank you for your response.

28 Jan 2013, 20:21
Anthony Shaw (138 posts)

No problem, glad you’re moving forward again.

You must be logged in to comment