Friday, February 24, 2012

[android-developers] Re: Problem with R class, ids and layouts not resolved

Here is what I guess is going on:

If you cut-and-paste stuff from one Project to another in Eclipse, and
the stuff you copy includes a reference to the "R" class, you will
find that Eclipse will set up an import of the R class for the project
you copied from. This seems to be reasonable behaviour for most
classes, but not for the R class where each Project has its own.

This means your code can be looking at the wrong verion of R.

Go through the class(es) which fail, and remove any imports for R. You
will get errors wherever you use R. Hover the mouse over one of the
errors, one of the options will be to import the correct R class.
Select this, and the errors in the class will be fixed.

On Feb 25, 12:49 am, Luigi Caradonna <luigi.carado...@gmail.com>
wrote:
> 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?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate