Android AppWidget地图活动问题

发布于 2024-07-27 12:53:32 字数 1561 浏览 3 评论 0 原文

正确的。

所以我有一个应用程序小部件。

它有 4 个按钮,其中一个按钮我希望它能在地图上显示用户的当前位置。

所以 - 我创建了一个新活动,如下所示:

package com.android.driverwidget;

import java.util.List;

import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;



public class MyLocation extends MapActivity{



        public void onCreate(Bundle icicle) {
          super.onCreate(icicle);

          setContentView(R.layout.main);

          MapView myMapView = (MapView)findViewById(R.id.mapview);
          MapController mapController = myMapView.getController();

          List<Overlay> overlays = myMapView.getOverlays();
          MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this,             myMapView);
          overlays.add(myLocationOverlay);
          myLocationOverlay.enableMyLocation();
        }


          protected boolean isRouteDisplayed() {

            return false;
          }




}

然后我将适当的使用库行添加到清单中

<activity android:name=".MyLocation"
    android:label="myLocation">
     </activity>

   <uses-library android:name="com.google.android.maps" />

还好 - 当我运行应用程序时,出现以下错误,看起来它找不到 MapActivity 类,我在 GoogleApps 上运行它1.5 也代替普通的 android 1.5。

http://pastebin.com/m3ee8dba2

请有人帮助我 - 我现在快死了。

Right.

So I have an app widget.

It has 4 buttons, one one of the buttons I want it to show me the current location of the user on the map.

So - I make a new activity as below:

package com.android.driverwidget;

import java.util.List;

import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;



public class MyLocation extends MapActivity{



        public void onCreate(Bundle icicle) {
          super.onCreate(icicle);

          setContentView(R.layout.main);

          MapView myMapView = (MapView)findViewById(R.id.mapview);
          MapController mapController = myMapView.getController();

          List<Overlay> overlays = myMapView.getOverlays();
          MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this,             myMapView);
          overlays.add(myLocationOverlay);
          myLocationOverlay.enableMyLocation();
        }


          protected boolean isRouteDisplayed() {

            return false;
          }




}

And then I added the appropriate uses library line to the manifest

<activity android:name=".MyLocation"
    android:label="myLocation">
     </activity>

   <uses-library android:name="com.google.android.maps" />

Ok yet - when I run the app the following errors occur, looks like it cannot find the MapActivity class, im running it on the GoogleApps 1.5 instead of normal android 1.5 as well.

http://pastebin.com/m3ee8dba2

Somebody plz help me - i am now dying.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沧桑㈠ 2024-08-03 12:53:32

修复您的清单。

<uses-library android:name="com.google.android.maps" />

通过添加/移动到应用程序

Fix your manifest by adding/moving

<uses-library android:name="com.google.android.maps" />

into application.

倚栏听风 2024-08-03 12:53:32

创建此项目时,您必须选择 Google APIs 项目,而不仅仅是 AVD。

When you creating this project you have to choose Google APIs project not only AVD.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文