1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Android程序 地图 在定制的Android应用程序中使用谷歌地图

Android程序 地图 在定制的Android应用程序中使用谷歌地图

时间:2023-03-10 15:34:53

相关推荐

Android程序 地图 在定制的Android应用程序中使用谷歌地图

我收到以下问题(显示在LogCat中)。我希望any1可以帮助我,因为我是android应用程序开发的新手。在定制的Android应用程序中使用谷歌地图

11-17 16:50:38.087: E/AndroidRuntime(372): FATAL EXCEPTION: main

11-17 16:50:38.087: E/AndroidRuntime(372): java.lang.IllegalStateException: Could not execute method of the activity

11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$1.onClick(View.java:2072)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View.performClick(View.java:2408)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$PerformClick.run(View.java:8816)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Handler.handleCallback(Handler.java:587)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Handler.dispatchMessagev(Handler.java:92)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Looper.loop(Looper.java:123)

11-17 16:50:38.087: E/AndroidRuntime(372): at android.app.ActivityThread.main(ActivityThread.java:4627)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invokeNative(Native Method)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invoke(Method.java:521)

11-17 16:50:38.087: E/AndroidRuntime(372): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

11-17 16:50:38.087: E/AndroidRuntime(372): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.NativeStart.main(Native Method)

11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.reflect.InvocationTargetException

11-17 16:50:38.087: E/AndroidRuntime(372): at com.mspl.activities.AlertListActivity.doShow(AlertListActivity.java:144)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invokeNative(Native Method)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invoke(Method.java:521)enter code here

11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$1.onClick(View.java:2067)

11-17 16:50:38.087: E/AndroidRuntime(372): ... 11 more

11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.NoClassDefFoundError: com.mspl.activities.AlertLocationActivity

11-17 16:50:38.087: E/AndroidRuntime(372): ... 15 more

11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.DexFile.defineClass(Native Method)

11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)

11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)

11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)

11-17 16:50:38.087: E/AndroidRuntime(372): ... 15 more

这是我AlertListActivity.java文件: -

package com.mspl.activities;

enter code here

import java.util.ArrayList;

import java.util.Date;

import java.util.HashMap;

import android.app.ListActivity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.LinearLayout;

import android.widget.ListView;

import android.widget.SimpleAdapter;

import android.widget.TextView;

public class AlertListActivity extends ListActivity {

static final ArrayList> list2 = new ArrayList>();

Date date;

HashMap map = new HashMap();

static int flag = 0;

SimpleAdapter a;

int selectedIndex = 0;

// AlertAdapter sa;

@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.alert);

//addContentView(R.layout.crowview,new ViewGroup.LayoutParams(this));

SimpleAdapter adapter = new SimpleAdapter(this, list2, R.layout.crowview, new String[] { "alert_type", "date", "identity"}, new int[] { R.id.alarmType, R.id.date, R.id.identity});

populateList();

a = adapter;

setListAdapter(adapter);

}

public void populateList() //Statically filling the ArrayList with HashMap values

{

if (flag == 0) // For entry to be entered only once

{

flag = 1;

map.put("alert_type", "Alert_1");

date = new Date(121, 11, 9, 17, 5, 00);

map.put("date", date.toString());

map.put("identity", "9001");

list2.add(map);

map = new HashMap();

map.put("alert_type", "Alert_2");

date = new Date(111, 11, 9, 17, 5, 05);

map.put("date", date.toString());

map.put("identity", "9002");

list2.add(map);

map = new HashMap();

map.put("alert_type", "Alert_3");

date = new Date(111, 11, 9, 17, 5, 10);

map.put("date", date.toString());

map.put("identity", "9003");

list2.add(map);

map = new HashMap();

map.put("alert_type", "Alert_4");

date = new Date(111, 11, 9, 17, 5, 15);

map.put("date", date.toString());

map.put("identity", "9004");

list2.add(map);

map = new HashMap();

map.put("alert_type", "Alert_5");

date = new Date(111, 11, 9, 17, 5, 20);

map.put("date", date.toString());

map.put("identity", "9005");

list2.add(map);

}

}

public void onAck(View view) //Performs Delete operation on Alert List

{

ListView lv1 = getListView();

// long i2 = lv1.getSelectedItemPosition();

//lv1.setSelection(i2);

// int i3 = view.getId();

//list2.remove(i2);

LinearLayout llv = (LinearLayout)view.getParent().getParent();

LinearLayout llv2 = (LinearLayout)llv.getChildAt(0);

TextView child = (TextView)llv2.getChildAt(0);

//Toast.makeText(getApplicationContext(),((TextView)child).getText(), Toast.LENGTH_SHORT).show();

for(int i=0 ; i

{

HashMap hm = list2.get(i);

String str = hm.get("identity");

if(str.equals(child.getText()))

{

list2.remove(i);

break;

}

}

lv1.refreshDrawableState();

a.notifyDataSetChanged();

a.notifyDataSetInvalidated();

}

public void doShow(View view)

{

try{

Intent intent = new Intent(AlertListActivity.this, AlertLocationActivity.class);

startActivity(intent);

}

catch(Exception e)

{

e.printStackTrace();

}

}

@Override

protected void onListItemClick(ListView l, View v, int position, long id) //Listener for ListView Item click

{

super.onListItemClick(l, v, position, id);

selectedIndex = position;

Object o = this.getListAdapter().getItem(position);

String str = o.toString();

// Toast.makeText(this, "You have chosen: " + " " + str,

// Toast.LENGTH_LONG).show();

Intent i = new Intent(this, AlertDetailsActivity.class);

i.putExtra("str", str);

startActivity(i);

}

}

这是我AlertLocationActivity.java文件: -

package com.mspl.activities;

import java.util.List;

import android.graphics.drawable.Drawable;

import android.os.Bundle;

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.OverlayItem;

public class AlertLocationActivity extends MapActivity

{

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.mapview);

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

mapView.setBuiltInZoomControls(true);

List mapOverlays = mapView.getOverlays();

Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

GeoPoint point = new GeoPoint(19240000,-99120000);

OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

itemizedoverlay.addOverlay(overlayitem);

mapOverlays.add(itemizedoverlay);

}

@Override

protected boolean isRouteDisplayed() {

return false;

}

}

AndroidManifest.xml文件: -

package="com.mspl.activities" android:versionCode="1"

android:versionName="1.0">

android:label="@string/vehicle.list.screen" />

android:label="@string/alert.list.screen" />

android:label="@string/alert2.list.screen" />

android:label="@string/alert.loc.screen" />

这是m Ÿmapview.xml文件: -

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:id="@+id/mapView"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:enabled="true"

android:clickable="true"

android:apiKey="0WYMWNJ2XW382cucH2luf4o6bRtkU7W6vROnlrg"

/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

/>

-11-17

Siddhant

+2

认真吗?我们不是通灵,请张贴一些源代码... –

+0

/questions/3621163/cannot-resolve-mapactivity-class-on-android –

+0

你有申报清单档案中的你AlertLocationActivity? –

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。