![]() | chapter 3 creating the opening screen error |
|
09 Jul 2011, 18:29
Mike M (5 posts) |
Ok, check out these code snips to see the errors I am getting. <cod> package org.example.sudoku;
import android.app.Activity;
import android.os.Bundle;
public class Sudoku extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
^^For this .java page I get the error
"Multiple markers at this line
- R cannot be resolved to a
variable
- main cannot be resolved or is
not a field"
I get the error next to the setContentView(R.layout.main); line
p.s. I just realized going back and looking at all
this I never had a r.java file. So i selected create
class R which creates a r.java file. Do I need to go
back and redo chapter three with a r.java file in its
folder? It never existed up to this point and now all i have is:
package org.example.sudoku;
public class R {
public static Object layout;
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="30dip"
android:orientation="horizontal"
>
^^On the main.xml I get an error at the android:backgroud="@color/background"
the error states "error: Error: No resource found that matches the given name (at 'background' with value
'@color/background')."
Any ideas? Also is there anyway to post screenshots on this forum? Thanks! |
|
12 Jul 2011, 01:59
Ed Burnette (1316 posts) |
You should not create the R.java file yourself. There’s no way to post screenshots here, but you can use some other photo or imaging service and post the link here. It sounds like maybe you put some of the resource files in the wrong directory. Or that the project didn’t get created as an Android project to start with. Download the sample code from this site, and look at the Sudokuv1 and Sudokuv2 examples, comparing them against yours. |
| You must be logged in to comment |

