On Dec 5, 10:15 pm, Romain Guy <romain...@android.com> wrote:
> The platform does not cache layout ids. It looks like your resources
> were recompiled but not the source code. Resources are compiled to
> generate static classes (like R.layout) which contain static fields
> (R.layout.main) which are themselves inlined when you compile your
> Java classes. If you regenerate the resources without recompiling the
> Java code, your compiled Java code will use the previously inlined
> static field and not the new one. So if you rename resources, simply
> perform a clean build of your project :)

Hm. Let's see the Java code has not changed.  What creates the
correspondence between the R.layout values and the actual layout
files?  The inlining is irrelevant isn't it?
>
>
>
> On Sat, Dec 5, 2009 at 10:09 PM, jotobjects <jotobje...@gmail.com> wrote:
> > I did replicate this problem.  It turns out my code was correct but
> > the platform can screw up the correspondence between the R.layout
> > values and the layout files - due perhaps to caching(?)
>
> > Here is how to show this problem.  The R.layout values are numbered in
> > order of the alphabetical order of the layout file names.
>
> > (1) Create a1.xml and main.xml layout files and install the app
> > (2) Rename a1.xml to mb.xml and reinstall the app
>
> > At this point mb.xml has the R.layout number that main.xml had the
> > first time the app was installed.  setContentView(R.layout.main) will
> > now inflate mb.xml instead of main.xml.  This is what was happening to
> > me - it was loading mymapview.xml when it should have been loading
> > main.xml.  You can have other kinds of problems also such as having it
> > try to load a layout file that no longer exists if you remove a layout
> > file and reinstall with fewer layout files.
>
> > I do not know of a workaround other than renaming the layout files
> > back to their original values.
>
> > The problem appears to be due to some kind of platform caching that
> > persists even if the application is removed.  Is there a bug already
> > filed for this problem?
>
> > On Dec 4, 9:43 am, jotobjects <jotobje...@gmail.com> wrote:
> >> Update on this - I stripped it down to a simple case and now the
> >> problem is not there :-).  I should add the main activity is an
> >> ActivityGroup that starts the MapActivity.  This is now working
> >> correctly with a separate layout file for the MapView.
>
> >> I'll try to isolate what I was doing wrong in the first attempt and
> >> post that information.
>
> >> On Dec 3, 4:11 pm, jotobjects <jotobje...@gmail.com> wrote:
>
> >> > Thanks.  I'll see if I can replicate the problem in a simple example
> >> > (the case I have has a lot of other stuff in it) and post that when I
> >> > get a chance.
>
> >> > On Dec 3, 3:49 pm, TreKing <treking...@gmail.com> wrote:
>
> >> > > What I meant was to make sure you were doing exactly what you posted,
> >> > > namely setContentView(R.layout.main); in your main activity
> >> > > and setContentView(R.layout. mymapvieww); in your MapActivity.
>
> >> > > What does your R.layout.main look like? Could you possibly have  
> >> > > reference
> >> > > to the mapview layout in there somehow?
> >> > > What happens if you try to set a different layout in your main activity
> >> > > (like a simple LinearLayout that does nothing)?
> >> > > Do you have anything else in onCreate() before setContentView()?
>
> >> > > Grasping at straws here ...
>
> >> > > -------------------------------------------------------------------------------------------------
> >> > > TreKing - Chicago transit tracking app for Android-powered 
> >> > > deviceshttp://sites.google.com/site/rezmobileapps/treking
>
> >> > > On Thu, Dec 3, 2009 at 4:55 PM, jotobjects <jotobje...@gmail.com> 
> >> > > wrote:
> >> > > > How do you "set the correct layout for the correct activity"?  Is
> >> > > > there something to put in the manifest or the layout file?  I'm doing
> >> > > > this in the main Activity -
>
> >> > > >            setContentView(R.layout.main);
>
> >> > > > and this in the MapActivity -
>
> >> > > >        setContentView(R.layout.mymapvieww);
>
> >> > > > It dies at the first step - setContentView(R.layout.main) with this
> >> > > > message "MapViews can only be created inside instances of
> >> > > > MapActivity".  If I remove the file layout/mymapview.xml the problem
> >> > > > goes away.
>
> >> > > > On Dec 3, 2:06 pm, TreKing <treking...@gmail.com> wrote:
> >> > > > > Sounds odd. I have the same setup (map activity that is launched 
> >> > > > > from a
> >> > > > > primary activity, each with their own layout) and have never seen
> >> > > > anything
> >> > > > > like that.
>
> >> > > > > I would double check your layouts and make sure that you are, in 
> >> > > > > fact,
> >> > > > > setting the correct layout for the correct activity. From the 
> >> > > > > error you
> >> > > > > mentioned it would appear that you have a mapview element in the 
> >> > > > > main
> >> > > > layout
> >> > > > > file or that you're loading the mapview layout by mistake in the 
> >> > > > > main
> >> > > > > activity.
>
> >> > > > > Otherwise maybe post some code and your layouts?
>
> >> > > > -------------------------------------------------------------------------------------------------
> >> > > > > TreKing - Chicago transit tracking app for Android-powered 
> >> > > > > deviceshttp://
> >> > > > sites.google.com/site/rezmobileapps/treking
>
> >> > > > > On Thu, Dec 3, 2009 at 3:13 PM, jotobjects <jotobje...@gmail.com> 
> >> > > > > wrote:
> >> > > > > > I am getting an error creating a MapView with a layout file.  
> >> > > > > > The app
> >> > > > > > has two activities with different layout files.  The main 
> >> > > > > > activity
> >> > > > > > launched from Home is not a MapAcitivity.  It starts the second
> >> > > > > > activity (MapActivity).  The error occurs in onCreate() for the 
> >> > > > > > first
> >> > > > > > Activity in setContentView(R.layout.main).  The error message is
>
> >> > > > > > "MapViews can only be created inside instances of MapActivity"
>
> >> > > > > > which makes sense except main.xml does not have a MapView 
> >> > > > > > element.
> >> > > > > > The intention was to to call setContentView(R.layout.mymapview) 
> >> > > > > > in the
> >> > > > > > MapActivity. But the MapView is being created with the context 
> >> > > > > > of the
> >> > > > > > main (non-map) Activity instead.
>
> >> > > > > > I have a workaround (directly instantiating the MapView without a
> >> > > > > > layout file) but just wondering if there is a way to control 
> >> > > > > > when the
> >> > > > > > layout file Views are created.
>
> >> > > > > > --
> >> > > > > > 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> >> > > > <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>
> >> > > > > > For more options, visit this group at
> >> > > > > >http://groups.google.com/group/android-developers?hl=en
>
> >> > > > --
> >> > > > 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> >> > > > For more options, visit this group at
> >> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > 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+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to