我的应用程序执行成功,问题是我在第二个XML布局上创建了按钮,将您带到地图(类+布局),我创建的方法将我带到课堂,但我遇到了问题 这是:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: inducesmile.com.androidloginandregistration, PID: 1726
android.content.ActivityNotFoundException: Unable to find explicit activity class {inducesmile.com.androidloginandregistration/inducesmile.com.androidloginandregistration.mapgs}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
at android.app.Activity.startActivityForResult(Activity.java:3424)
at android.app.Activity.startActivityForResult(Activity.java:3385)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748)
at android.app.Activity.startActivity(Activity.java:3627)
at android.app.Activity.startActivity(Activity.java:3595)
at inducesmile.com.androidloginandregistration.CustomerActivity.mapfragobject(CustomerActivity.java:190)
at inducesmile.com.androidloginandregistration.CustomerActivity$1.onClick(CustomerActivity.java:85)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
我认为问题在于调用类的对象
onclick:
position.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.mapgs);
mapfragobject(mapView );
}
});
调用方法
public void mapfragobject (View view) {
Intent intent = new Intent(this, mapgs.class);
startActivity(intent);
}
第一条评论后的新错误:
AndroidRuntime: FATAL EXCEPTION: main
Process: inducesmile.com.androidloginandregistration, PID: 1741
java.lang.RuntimeException: Unable to start activity ComponentInfo{inducesmile.com.androidloginandregistration/inducesmile.com.androidloginandregistration.mapgs}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at inducesmile.com.androidloginandregistration.mapgs.onCreate(mapgs.java:26)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)