Google Maps API示例项目MainActivity.java中的错误
我试图使用Google Play服务的Google地图演示,但在两行示例代码中返回了错误。返回错误的代码如下所示:Google Maps API示例项目MainActivity.java中的错误,java,android,google-maps,Java,Android,Google Maps,我试图使用Google Play服务的Google地图演示,但在两行示例代码中返回了错误。返回错误的代码如下所示: new DemoDetails(R.string.circle_demo, R.string.circle_description, CircleDemoActivity.class), 第一行的错误是“构造函数MainActivity.DemodMetals(int,int,Class)未定义。” 第二个错误是“CircleDemoActivit
new DemoDetails(R.string.circle_demo, R.string.circle_description,
CircleDemoActivity.class),
第一行的错误是“构造函数MainActivity.DemodMetals(int,int,Class)未定义。”
第二个错误是“CircleDemoActivity无法解析为类型。”
这可能是一件微不足道的事情,我是Android开发新手,所以请原谅我缺乏专业知识
以下是MainActivity.java中的其余代码:
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.mapdemo;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.example.mapdemo.view.FeatureView;
/**
* The main activity of the API library demo gallery.
* <p>
* The main layout lists the demonstrated features, with buttons to launch them.
*/
public final class MainActivity extends ListActivity {
/**
* A simple POJO that holds the details about the demo that are used by the List Adapter.
*/
private static class DemoDetails {
/**
* The resource id of the title of the demo.
*/
private final int titleId;
/**
* The resources id of the description of the demo.
*/
private final int descriptionId;
/**
* The demo activity's class.
*/
private final Class<? extends FragmentActivity> activityClass;
public DemoDetails(
int titleId, int descriptionId, Class<? extends FragmentActivity> activityClass) {
super();
this.titleId = titleId;
this.descriptionId = descriptionId;
this.activityClass = activityClass;
}
}
/**
* A custom array adapter that shows a {@link FeatureView} containing details about the demo.
*/
private static class CustomArrayAdapter extends ArrayAdapter<DemoDetails> {
/**
* @param demos An array containing the details of the demos to be displayed.
*/
public CustomArrayAdapter(Context context, DemoDetails[] demos) {
super(context, R.layout.feature, R.id.title, demos);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
FeatureView featureView;
if (convertView instanceof FeatureView) {
featureView = (FeatureView) convertView;
} else {
featureView = new FeatureView(getContext());
}
DemoDetails demo = getItem(position);
featureView.setTitleId(demo.titleId);
featureView.setDescriptionId(demo.descriptionId);
return featureView;
}
}
private static final DemoDetails[] demos = {new DemoDetails(
R.string.basic_map, R.string.basic_description, BasicMapActivity.class),
new DemoDetails(R.string.camera_demo, R.string.camera_description,
CameraDemoActivity.class),
new DemoDetails(R.string.events_demo, R.string.events_description,
EventsDemoActivity.class),
new DemoDetails(R.string.layers_demo, R.string.layers_description,
LayersDemoActivity.class),
new DemoDetails(
R.string.locationsource_demo, R.string.locationsource_description,
LocationSourceDemoActivity.class),
new DemoDetails(R.string.uisettings_demo, R.string.uisettings_description,
UiSettingsDemoActivity.class),
new DemoDetails(R.string.groundoverlay_demo, R.string.groundoverlay_description,
GroundOverlayDemoActivity.class),
new DemoDetails(R.string.marker_demo, R.string.marker_description,
MarkerDemoActivity.class),
new DemoDetails(R.string.polygon_demo, R.string.polygon_description,
PolygonDemoActivity.class),
new DemoDetails(R.string.polyline_demo, R.string.polyline_description,
PolylineDemoActivity.class),
new DemoDetails(R.string.circle_demo, R.string.circle_description,
CircleDemoActivity.class),
new DemoDetails(R.string.tile_overlay_demo, R.string.tile_overlay_description,
TileOverlayDemoActivity.class),
new DemoDetails(R.string.options_demo, R.string.options_description,
OptionsDemoActivity.class),
new DemoDetails(R.string.multi_map_demo, R.string.multi_map_description,
MultiMapDemoActivity.class),
new DemoDetails(R.string.retain_map, R.string.retain_map_description,
RetainMapActivity.class),
new DemoDetails(R.string.raw_mapview_demo, R.string.raw_mapview_description,
RawMapViewDemoActivity.class),
new DemoDetails(R.string.programmatic_demo, R.string.programmatic_description,
ProgrammaticDemoActivity.class)};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListAdapter adapter = new CustomArrayAdapter(this, demos);
setListAdapter(adapter);
}
/*
*版权所有(C)2012安卓开源项目
*
*根据Apache许可证2.0版(以下简称“许可证”)获得许可;
*除非遵守许可证,否则不得使用此文件。
*您可以通过以下方式获得许可证副本:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*除非适用法律要求或书面同意,软件
*根据许可证进行的分发是按“原样”进行分发的,
*无任何明示或暗示的保证或条件。
*请参阅许可证以了解管理权限和权限的特定语言
*许可证下的限制。
*/
包com.example.mapdemo;
导入android.app.ListActivity;
导入android.content.Context;
导入android.content.Intent;
导入android.os.Bundle;
导入android.support.v4.app.FragmentActivity;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.ArrayAdapter;
导入android.widget.ListAdapter;
导入android.widget.ListView;
导入com.example.mapdemo.view.FeatureView;
/**
*API库演示库的主要活动。
*
*主布局列出了演示的功能,以及启动这些功能的按钮。
*/
公共最终类MainActivity扩展了ListActivity{
/**
*一个简单的POJO,包含列表适配器使用的演示的详细信息。
*/
专用静态类解调器{
/**
*演示标题的资源id。
*/
私人最终int标题;
/**
*演示说明的资源id。
*/
私有最终整数描述ID;
/**
*演示活动的类。
*/
private final Class缺少CircleDemoActivity。添加它可以解决您的问题
或者从您的文件中删除对它的所有引用…显示CircleDemoActivity.javah的代码!没有CircleDemoActivity文件。但它在清单文件中声明为活动。嗯,这可能是一个树桩。删除了CircleDemo的代码。不确定这是否是原因,但应用程序会在模拟器上运行并立即崩溃。添加您的logc现在,我来回答这个问题。你是否在清单文件中删除了它?我删除了,但我读到谷歌地图API不适用于模拟器…我猜这就是问题所在。不过,如果你好奇的话,我会发布日志。