small medium large xlarge

Back to: All Forums  Hello, Android
07 Feb 2014, 17:59
angelica perez (1 post)

Hi, I am working on the Sudoku in Hello, Android and am having two problems that I feel are connected. In my file, I have this code:

package com.example.sudoku1; import android.os.Bundle; import android.preference.PreferenceActivity; public class Prefs extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); } } Eclipse highlights the “xml” in “R.xml.settings” and says “xml cannot be resolved or is not a field.”

In my, I have this method:

@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case startActivity(new Intent(this, Prefs.class)); return true; // More items go here (if any) … } return false; } Eclipse highlights “settings” in “case;” and says “settings cannot be resolved or is not a field.”

My Prefs ad Sudoku java files are located in the src folder. My settings.xml is located in my res/xml/ folder.

My import statements for sudoku are:

import android.os.Bundle; import; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.content.Intent; import android.view.View; import android.view.View.OnClickListener;

For Prefs they are

import android.os.Bundle; import android.preference.PreferenceActivity;

Do you know what my error is?

  You must be logged in to comment