I just started using MapFragments, and I can get the Map to show in my Activity. I just use a simple XML-layout, and it works as expected:
Now, I need to get the Fragment in code, so I can start interacting with the Map. This is where I run into problems:
As you can see, the MapFragment (or getFragmentManager) cannot be resolved to a type. I am targeting Android 4, API level 17:
and you can also see that I am referencing the Googke Play library.
Here is the Manifest, just for clarity:
So, the big question is: why can't I resolve MapFragment? What am I missing?
As a side note: SupportMapFragment seems to resolve OK, but that's not what I want.
To use MapFragment
, you need the Android library project attached to your app (as you had) and the import
statement for com.google.android.gms.maps.MapFragment
. Based on your comments, the latter part was the issue.
Usually, Eclipse suggest to import it by itself, so I never thought of doing it manually.
I have run into that problem on occasion as well, where -- steadfastly refuses to add an import. I have not been able to come up with a reproducible scenario, and it happens infrequently enough that I just shrug, add it manually, and move along to other things. I'm also uncertain whether the problem is with Eclipse or with any ADT extensions to the import resolver.
Besides, I went without Eclipse for a long time in Android development, typing in import
statements manually, and so I'm kinda used to it.
Btw, you answer a lot of questions here on SO, do you have time for anything else? ;-)
I am a fast typist, courtesy of several years as a teenager typing on a manual typewriter.
(For you young'uns reading this, a "typewriter" was basically a keyboard directly connected to a printer, and a "manual typewriter" was one that use the mechanical action of pressing the keys to actually put the letters on the paper, and therefore worked without electricity. Also, you are cordially invited to get off my lawn.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With