當我嘗試運行我的應用程序時,我的應用程序崩潰。它在日誌文件中顯示一些錯誤。以下是日誌文件中顯示的錯誤。應用程序崩潰
請幫忙解決這個錯誤。
LOG文件
08-20 23:04:41.766: E/AndroidRuntime(8695): FATAL EXCEPTION: main
08-20 23:04:41.766: E/AndroidRuntime(8695): Process: com.example.er.wolfpack, PID: 8695
08-20 23:04:41.766: E/AndroidRuntime(8695): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.er.wolfpack/com.example.er.wolfpack.MainActivity}: java.lang.NullPointerException
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2318)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread.access$800(ActivityThread.java:139)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.os.Handler.dispatchMessage(Handler.java:102)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.os.Looper.loop(Looper.java:149)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread.main(ActivityThread.java:5257)
08-20 23:04:41.766: E/AndroidRuntime(8695): at java.lang.reflect.Method.invokeNative(Native Method)
08-20 23:04:41.766: E/AndroidRuntime(8695): at java.lang.reflect.Method.invoke(Method.java:515)
08-20 23:04:41.766: E/AndroidRuntime(8695): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-20 23:04:41.766: E/AndroidRuntime(8695): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
08-20 23:04:41.766: E/AndroidRuntime(8695): at dalvik.system.NativeStart.main(Native Method)
08-20 23:04:41.766: E/AndroidRuntime(8695): Caused by: java.lang.NullPointerException
08-20 23:04:41.766: E/AndroidRuntime(8695): at com.example.er.wolfpack.MainActivity.onCreate(MainActivity.java:26)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.Activity.performCreate(Activity.java:5411)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-20 23:04:41.766: E/AndroidRuntime(8695): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
08-20 23:04:41.766: E/AndroidRuntime(8695): ... 11 more
public class MainActivity extends Activity implements View.OnClickListener {
ImageView im1;
TextView tv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
tv1=(TextView)findViewById(R.id.textView1);
im1=(ImageView)findViewById(R.id.imageView1);
tv1.setOnClickListener(this);
im1.setOnClickListener(this);
}
@Override
public void onClick(View v) {
startActivity(new Intent(this,Login.class));
}
}
MainActivity.java中的第26行是什麼? – Lal