android - R.java doesn't have map for R.id.map -
so i'm following this guide letter (or @ least trying to).
and aside having import things not specified in guide, fine except there red squiggle can't explain.
in line:
googlemap map = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)).getmap();
there red mark under "map" in "r.id.map".
import com.google.android.gms.common.googleplayservicesutil; import com.google.android.gms.maps.*; import android.os.bundle; import android.app.activity; import android.support.v4.app.fragmentactivity; import android.view.menu; public class mainactivity extends fragmentactivity { @override protected void oncreate(bundle savedinstancestate) { googleplayservicesutil.isgoogleplayservicesavailable(getapplicationcontext()); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); googlemap map = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)).getmap(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
i have included android-support-v4.jar buildpath , have downloaded correctly google sdk (including google play services). have api key too. apparently should working now.
seems me step 7 1 missing resource comes from:
update res/layout/activity_main.xml , replace entire contents
<fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment"/>
in eclipse need to:
- change file
- save it
- clean project (to regenerate resoureces, among them r.java)
Comments
Post a Comment