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>
我的logcat错误 03-06 16:22:41.812:ERROR / AndroidRuntime(219):未捕获的处理程序:由于未捕获的异常而导致主线程退出
03-06 16:22:41.883:ERROR / AndroidRuntime(219):java.lang.NoClassDefFoundError:com.onclick.a
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.onclick.onclick $ 1.onClick(onclick.java:22)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.View.performClick(View.java:2364)
03-06 16:22:41.883:ERROR / AndroidRuntime(219)在android.view.View.onTouchEvent(View.java:4179) 03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.widget.TextView.onTouchEvent(TextView.java:6540)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.View.dispatchTouchEvent(View.java:3709)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.os.Handler.dispatchMessage(Handler.java:99)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):在android.os.Looper.loop(Looper.java:123)
03-06 16:22:41.883:ERROR / 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:ERROR / AndroidRuntime(219):at java.lang.reflect.Method.invoke(Method.java:521)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-06 16:22:41.883:ERROR / AndroidRuntime(219):at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
确保您的清单和所有java文件中的包名正确无误