0

my xml code is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >
<com.google.android.maps.MapView
 android:id="@+id/mapView"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:enable="true"
 android:clickable="true"
 android:apiKey="0THdCiXY7jaJ9Br1ZQahFE4Lu1xTv1hAiVJBvxQ"
 />
</RelativeLayout>

and manifest is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.google.haha"
 android:versionCode="1"
 android:versionName="1.0">
 <uses-sdk android:minSdkVersion="8" />
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 <application android:icon="@drawable/icon" android:label="@string/app_name">
 <uses-library android:name="com.google.android.maps"/> 
 <activity android:name=".NewActivity"
 android:label="@string/app_name">
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
 </activity>
 </application>
</manifest>

And this is main code:

package com.google.haha;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.app.Activity;
import android.os.Bundle;
public class NewActivity extends MapActivity {
 /** Called when the activity is first created. */
 MapController mControl;
 GeoPoint GeoP;
 MapView mapV;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 mapV=(MapView)findViewById(R.id.mapView);
 mapV.displayZoomControls(true);
 mapV.setBuiltInZoomControls(true);
 double lat=21.00;
 double longi=79.00;
 GeoP=new GeoPoint((int)(lat*1E6),(int)(longi*1E6));
 mControl=mapV.getController();
 mControl.animateTo(GeoP);
 mControl.setZoom(12);
 }
 @Override
 protected boolean isRouteDisplayed() {
 // TODO Auto-generated method stub
 return false;
 }
}

Everything is fine but I am getting error an on line:

mapV=(MapView)findViewById(R.id.mapView);

id field is not recognised.

GSerg
78.9k18 gold badges173 silver badges377 bronze badges
asked Jun 18, 2011 at 17:33
4
  • You know this problem comes up a lot. I know it has something to do with the import of the pre-compiled resources folder. I never did figure out why sometimes I needed to import it directly and why sometimes Eclipse handled the dependency. Commented Jun 18, 2011 at 17:58
  • 1
    The first thing you should is to clean your project, Project->Clean in main menu. Maybe this will help. Commented Jun 18, 2011 at 17:59
  • I'm not quite sure what you mean by the error, but you may try cleaning the project. That should recompile your R.java file. Commented Jun 18, 2011 at 18:00
  • thanks everybody, that prob is resolved but nw i came up with other prob... m getting only gray tiles not maps... ny idea why dis hppning??? Commented Jun 19, 2011 at 13:38

2 Answers 2

2

try to clean and rebuild your project, because that problem comes up sometimes on Eclipse IDE , the id of your MapView is not recognised on your R.java file :

Project ==> Clean ==> Choose your Project and Clic OK

answered Jun 18, 2011 at 18:20
Sign up to request clarification or add additional context in comments.

Comments

0
<com.google.android.maps.MapView
 android:id="@+id/mapView"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 **android:enable="true"** MUST BE android:enabled="true"
 android:clickable="true"
 android:apiKey="0THdCiXY7jaJ9Br1ZQahFE4Lu1xTv1hAiVJBvxQ"
 />
</RelativeLayout>
takrl
6,5003 gold badges64 silver badges71 bronze badges
answered Jul 9, 2011 at 15:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.