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 devices http://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