• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem with R class, ids not resolved

Kumidan

Newbie
The problem of my app is that in the onCreate() method I have some "cannot be resolved or is not a field" errors.

Lines where I have the problem are:

setContentView(R.layout.main); //problem on main
AutoCompleteTextView textStationFrom = (AutoCompleteTextView) findViewById(R.id.stationfrom);// problem on stationfrom
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, STATIONS); //problem on list_item
AutoCompleteTextView textStationTo = (AutoCompleteTextView) findViewById(R.id.stationto); //problem on stationto
mPickDate = (EditText) findViewById(R.id.pickdate); //problem on pickdate
mPickTime = (EditText) findViewById(R.id.picktime); //problem on picktime

Inside R.java class I have
public static final class id {
public static final int pickdate=0x7f050003;
public static final int picktime=0x7f050005;
public static final int stationfrom=0x7f050000;
public static final int stationto=0x7f050002;
/**** other ids ****/
}
public static final class layout {
public static final int list_item=0x7f030000;
public static final int main=0x7f030001;
}

And of course inside the layout folder I have both main.xml and list_item.xml, all the resources have lower case names.

What's the problem?
 
I don't know if it has been a coincidence or not, but I've moved my workspace into a folder different from users/myaccount/workspace to c:\eclipse\workspace and now it works.
It was probably a problem due to restricted access to the folder, I'm using Win 7 Ultimate.
 
The problem of my app is that in the onCreate() method I have some "cannot be resolved or is not a field" errors.

Lines where I have the problem are:

setContentView(R.layout.main); //problem on main
AutoCompleteTextView textStationFrom = (AutoCompleteTextView) findViewById(R.id.stationfrom);// problem on stationfrom
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, STATIONS); //problem on list_item
AutoCompleteTextView textStationTo = (AutoCompleteTextView) findViewById(R.id.stationto); //problem on stationto
mPickDate = (EditText) findViewById(R.id.pickdate); //problem on pickdate
mPickTime = (EditText) findViewById(R.id.picktime); //problem on picktime

Inside R.java class I have
public static final class id {
public static final int pickdate=0x7f050003;
public static final int picktime=0x7f050005;
public static final int stationfrom=0x7f050000;
public static final int stationto=0x7f050002;
/**** other ids ****/
}
public static final class layout {
public static final int list_item=0x7f030000;
public static final int main=0x7f030001;
}

And of course inside the layout folder I have both main.xml and list_item.xml, all the resources have lower case names.

What's the problem?

When I have this problem, its usually caused by the code having an import R at the top that was added in automatically by eclipse. try deleting that if you ever run into this problem again.
 
Back
Top Bottom