我的谷歌地图应用程序有一点问题,我想使用这个 tutorial为了使用我的 Eclipse,我已经更新了所有 Elipse ADT,下载了 GoogleAPI,但我仍然从 IDE 收到错误,即要扩展我的 HelloWorld 应用程序的 MapActivity 无法解析为类型。我是否缺少一些需要在 Eclipse 本身上执行才能使其正常工作的重要导入或设置?
public class HelloGoogleMapActivity extends MapActivity {
/** Called when the activity is first created. */
@override
protected boolean isRoundDisplayed()
{
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapv=(MapView)findViewById(R.id.mapview);
mapv.setBuildInZoomControls(true);
}
}
此外,第一个“@override”关键字被报告为非法,我不知道为什么。
[更新]
提供的所有答案都是正确的。最正确的是下面的评论。感谢您的代码 fragment 。酷!
最佳答案
对于 @Override 异常 jst 从项目属性中更改一次 javacompiler ...JDK 合规性 1.6 到 1.5,然后再次将其设置为 1.6...我面临着同样的问题..这是一些 jdk 构建项目的 bcz。 ..或 eclipse 问题...
对于 map 概率
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/showmap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:apiKey="@string/mapkey"
android:clickable="true" />
</RelativeLayout>
Activity .java
MapView mapView;
@Override
protected void onCreate(Bundle icicle) {
try {
super.onCreate(icicle);
setContentView(R.layout.map_screen);
mapView = (MapView) findViewById(R.id.showmap);
mapView.setBuiltInZoomControls(true);
final MapController mc = mapView.getController();
mc.animateTo(new GeoPoint(((int) (latitude * 1E6) - 10),
((int) (longitude * 1E6)) - 10));
mc.setZoom(5);
} catch (Exception e) {
Log.e("MapCreate", e.getMessage());
}
ApplicationManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="Andro Integration"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<uses-library android:name="com.google.android.maps" />
<!-- <activity -->
<!-- </activity> -->
</application>
关于java - 添加了 GoogleAPI,但 MapActivity 变得不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10186065/