Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 活动启动时应用程序崩溃_Android_Nullpointerexception - Fatal编程技术网

Android 活动启动时应用程序崩溃

Android 活动启动时应用程序崩溃,android,nullpointerexception,Android,Nullpointerexception,当活动加载时,应用程序正在崩溃,但如果我将Make Register文本取消注释为指向网站的链接,代码会工作,但代码的完全相同副本只是不同的链接会使应用程序崩溃,代码如下 该活动用于登录页面,其中包含注册和重置密码的链接 LogCat 08-04 21:34:07.006 11888-11888/net.twistedcircuits.greenroadsmalta D/LOGIN PAGE: ______login page loaded 08-04 21:34:07.006 11888-1

当活动加载时,应用程序正在崩溃,但如果我将Make Register文本取消注释为指向网站的链接,代码会工作,但代码的完全相同副本只是不同的链接会使应用程序崩溃,代码如下

该活动用于登录页面,其中包含注册和重置密码的链接

LogCat

08-04 21:34:07.006 11888-11888/net.twistedcircuits.greenroadsmalta 
D/LOGIN PAGE: ______login page loaded
08-04 21:34:07.006 11888-11888/net.twistedcircuits.greenroadsmalta D/AndroidRuntime: Shutting down VM
    08-04 21:34:07.007 11888-11888/net.twistedcircuits.greenroadsmalta E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                         Process: net.twistedcircuits.greenroadsmalta, PID: 11888
                                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{net.twistedcircuits.greenroadsmalta/net.twistedcircuits.greenroadsmalta.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setMovementMethod(android.text.method.MovementMethod)' on a null object reference
                                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
                                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
                                                                                             at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
                                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                             at android.os.Looper.loop(Looper.java:154)
                                                                                             at android.app.ActivityThread.main(ActivityThread.java:6692)
                                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
                                                                                          Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setMovementMethod(android.text.method.MovementMethod)' on a null object reference
                                                                                             at net.twistedcircuits.greenroadsmalta.LoginActivity.onCreate(LoginActivity.java:56)
                                                                                             at android.app.Activity.performCreate(Activity.java:6912)
                                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
                                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)
                                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985) 
                                                                                             at android.app.ActivityThread.-wrap14(ActivityThread.java) 
                                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635) 
                                                                                             at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                             at android.os.Looper.loop(Looper.java:154) 
                                                                                             at android.app.ActivityThread.main(ActivityThread.java:6692) 
                                                                                             at java.lang.reflect.Method.invoke(Native Method) 
                                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 
                                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 
活动

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        //lock screen for always Portrait mode
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        Log.d("LOGIN PAGE","______login page loaded");

        loginEmail = (EditText) (findViewById(R.id.LoginEmail_editText));
        loginPassword = (EditText) (findViewById(R.id.LoginPassword_editText));


        //************************ Make Register text as link to website ************************//
/*
        registerLinkText = (TextView) (findViewById(R.id.registerLink_textView));
        registerLinkText.setClickable(true);
        registerLinkText.setMovementMethod(LinkMovementMethod.getInstance());

        register_text = "<a href='http://www.google.com'>No account yet? Create One</a>";
        registerLinkText.setText(fromHtml(register_text));
        registerLinkText.setLinkTextColor(getResources().getColor(R.color.loginTextColor));
*/
        //**********************************************************************************//

        //************************ Make Lost Password text as link to website ************************//
        lostPasswordLinkText = (TextView) (findViewById(R.id.lostPasswordLink_textView));
        lostPasswordLinkText.setClickable(true);
        registerLinkText.setMovementMethod(LinkMovementMethod.getInstance());

        password_text = "<a href='https://www.google.com.mt/search?q=dementia&spell=1&sa=X&ved=0ahUKEwiWyovunL7VAhXDzRQKHa2ND_0QBQgkKAA&biw=1152&bih=956'>Forgot your password?</a>";
        lostPasswordLinkText.setText(fromHtml(password_text));
        lostPasswordLinkText.setLinkTextColor(getResources().getColor(R.color.loginTextColor));
    }
}
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u登录);
//锁定屏幕,始终处于纵向模式
setRequestedOrientation(ActivityInfo.SCREEN\u ORIENTATION\u Picture);
Log.d(“登录页面”,“加载的登录页面”);
loginEmail=(EditText)(findViewById(R.id.loginEmail_EditText));
loginPassword=(EditText)(findViewById(R.id.loginPassword_EditText));
//************************使注册文本成为网站的链接************************//
/*
registerLinkText=(TextView)(findviewbyd(R.id.registerLink_TextView));
registerLinkText.setClickable(真);
registerLinkText.setMovementMethod(LinkMovementMethod.getInstance());
register_text=“”;
registerLinkText.setText(fromHtml(register_text));
registerLinkText.setLinkTextColor(getResources().getColor(R.color.loginTextColor));
*/
//**********************************************************************************//
//************************将丢失的密码文本作为网站链接************************//
lostPasswordLinkText=(TextView)(findViewById(R.id.lostPasswordLink_TextView));
lostPasswordLinkText.setClickable(真);
registerLinkText.setMovementMethod(LinkMovementMethod.getInstance());
密码_text=“”;
lostPasswordLinkText.setText(fromHtml(密码文本));
lostPasswordLinkText.setLinkTextColor(getResources().getColor(R.color.loginTextColor));
}
}

注册表链接文本
为空。它尚未绑定到xml布局中的视图

registerLinkText = (TextView) (findViewById(R.id.registerLink_textView));

取消上面这一行的注释。

如果我取消上面这一行的注释,这一部分会起作用,但问题是下面的代码块//****将丢失的密码文本作为网站链接******//AAAA Shot收到了谢谢:)