在android中点击按钮显示地图

嘿家伙我想要显示一个按钮点击地图...为此,我已经实现了2个类。一个类有一个按钮和一个意图调用,而第二个类显示地图。在运行该应用程序的按钮是显示,但点击它应用程序崩溃。 onclick.java

 
public class onclick extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btnOpen = (Button) findViewById(R.id.btnSave);
        btnOpen.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
               // TODO Auto-generated method stub
               Intent myIntent=new Intent(onclick.this,a.class);
               startActivity(myIntent);

            }
         });
    }
}

a.java

package com.onclick; 
public class a extends MapActivity{
   private MapView mapView;

@Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.f); mapView = (MapView)findViewById(R.id.map_view); mapView.setStreetView(true); } }

在AndroidManifest.xml中,我提供了互联网许可,也使用了com.google.android.maps和<activity android:name=".a"></activity>

家伙plzz帮助我...任何帮助将非常感激

我的logcat错误03-06 16:22:41.812:错误/ AndroidRuntime(219):未捕获的处理程序:由于未捕获的异常,线程主要退出

03-06 16:22:41.883:错误/ AndroidRuntime(219):java.lang.NoClassDefFoundError:com.onclick.a

03-06 16:22:41.883:错误/ AndroidRuntime(219):在com.onclick.onclick $ 1.onClick(onclick.java:22)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.View.performClick(View.java:2364)

03-06 16:22:41.883:错误/ AndroidRuntime(219)在android.view.View.onTouchEvent(View.java:4179)03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.widget .TextView.onTouchEvent(TextView.java:6540)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.View.dispatchTouchEvent(View.java:3709)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)

03-06 16:22:41.883:错误/ AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.app.Activity.dispatchTouchEvent(Activity.java:2061)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent(PhoneWindow.java:1643)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.view.ViewRoot.handleMessage(ViewRoot.java:1691)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.os.Handler.dispatchMessage(Handler.java:99)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.os.Looper.loop(Looper.java:123)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在android.app.ActivityThread.main(ActivityThread.java:4363)

03-06 16:22:41.883:ERROR / AndroidRuntime(219):at java.lang.reflect.Method.invokeNative(Native Method)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在java.lang.reflect.Method.invoke(Method.java:521)

03-06 16:22:41.883:错误/ AndroidRuntime(219):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860)

03-06 16:22:41.883:错误/ AndroidRuntime(219):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

03-06 16:22:41.883:错误/ AndroidRuntime(219):在dalvik.system.NativeStart.main(本机方法)


确保你的包名在你的清单和所有java文件中都是正确的

链接地址: http://www.djcxy.com/p/18349.html

上一篇: display map on click of a button in android

下一篇: Handling Exception in a MediaFile app