图形页面不能得到解决或不是场 [英] MapView cannot be resolved or is not a field

查看:213
本文介绍了图形页面不能得到解决或不是场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新来的Andr​​oid编程和Eclipse的工作。我有一个错误在下面的节目图形页面不能得到解决或不是场:

Hi I am new to Android programming and working on Eclipse. I am having an error "MapView cannot be resolved or is not a field" in the following program:

   import java.util.List;

   import android.app.AlertDialog;
   import android.content.DialogInterface;
   import android.content.Intent;
   import android.graphics.Canvas;
   import android.graphics.Paint;
   import android.graphics.Point;
   import android.graphics.RectF;
   import android.location.Location;
   import android.os.Bundle;
   import android.view.MotionEvent;


  import com.google.android.maps.GeoPoint;
  import com.google.android.maps.MapActivity;
  import com.google.android.maps.MapView;
  import com.google.android.maps.Overlay;
  import com.google.android.maps.Projection;

public class Map extends MapActivity {

MapView map;
long start;
long stop;
private final int mRadius = 5;

public void onCreate(Bundle SavedInstanceState) {
    super.onCreate(SavedInstanceState);
    setContentView(R.layout.mapview);
    map = (MapView)findViewById(R.id.mvMapview);
    map.setBuiltInZoomControls(true);
    map.displayZoomControls(true);
    map.setSatellite(true);
    map.setStreetView(true);
    Touchy t = new Touchy();
    List<Overlay> overlaylist = map.getOverlays();
    overlaylist.add(t);

    }
    public void draw(Canvas canvas, MapView mapView, boolean shadow){
    Projection projection = mapView.getProjection();

    if (shadow == false) {
        Bundle extras = getIntent().getExtras();{
            if(extras!=null){
                String longitude =extras.getString("Longitude");
                String latitude =extras.getString("Latitude");
            }
        }

        double latitude;
        double longitude; 
        GeoPoint geoPoint;
        geoPoint = new GeoPoint((int) ( latitude *1E6), (int) (longitude * 1E6));

        Point point = new Point();
        projection.toPixels(geoPoint, point);
        RectF oval = new RectF(point.x - mRadius, point.y - mRadius, point.x + mRadius, point.y + mRadius);

        Paint paint = new Paint();
        paint.setARGB(250, 255, 255, 255);
        paint.setAntiAlias(true);
        paint.setFakeBoldText(true);

        Paint backPaint = new Paint();
        backPaint.setARGB(175, 50, 50, 50);
        backPaint.setAntiAlias(true);
        RectF backRect = new RectF(point.x + 2 + mRadius, point.y - 3*mRadius, point.x + 65, point.y + mRadius);

        canvas.drawOval(oval, paint);
        canvas.drawRoundRect(backRect, 5, 5, backPaint);
        canvas.drawText("This is it", point.x + 2*mRadius, point.y,paint);
}
    super.draw(canvas.MapView.shadow);      
}

我不knw为什么这个错误弹出。
我alrdy尝试修复它,但图形页面错误是永远存在的。

I don knw why this error pop up. I alrdy try to fix it but the mapview error is always there

推荐答案

选择项目>从Eclipse主菜单属性。在属性窗口中,点击Android在左侧的类别列表中。然后,选择包含在右边的清单中的谷歌API的构建目标。单击确定关闭该窗口。

Choose Project > Properties from the Eclipse main menu. In the Properties window, click on Android in the list of categories on the left. Then, choose a build target that contains the Google APIs in the checklist on the right. Click OK to close the window.

这篇关于图形页面不能得到解决或不是场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆