2017-12-17 2 views
-5

Ich habe diesen Code, den ich in Android-Projekt geschrieben habe, um eine neue Ansicht zu öffnen, aber wenn die Schaltfläche geklickt wird, funktioniert die App nicht mehr, gibt aber keinen Fehler auf der Debugger-Konsole zurück. außer für ein Protokoll der AppApp wird heruntergefahren, wenn die Schaltfläche geklickt wird

Hier geschlossen sagen, ist mein Code

public class LoginActivity extends Activity{ 
     private Button btnLinkToRegister; 
     btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen); 

    // Link to Register Screen 
    btnLinkToRegister.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View view) { 
      Intent i = new Intent(getApplicationContext(), 
        RegisterActivity.class); 
      startActivity(i); 
      finish(); 
     } 
    }); 

}

ich andere Codes entfernt haben, um es einfach, das Problem

Hier ist das Protokoll zu identifizieren Katze

12-17 10:16:08.525 4039-4039/? I/zygote: Not late-enabling -Xcheck:jni (already on) 
    12-17 10:16:08.541 4039-4039/? W/zygote: Unexpected CPU variant for X86 using defaults: x86 
    12-17 10:16:08.726 4039-4039/com.otemainc.smartmenu I/InstantRun: starting instant run server: is main process 
    12-17 10:16:08.878 4039-4039/com.otemainc.smartmenu I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead. 
    12-17 10:16:08.952 4039-4062/com.otemainc.smartmenu D/OpenGLRenderer: HWUI GL Pipeline 
    12-17 10:16:09.015 4039-4062/com.otemainc.smartmenu I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0 
    12-17 10:16:09.015 4039-4062/com.otemainc.smartmenu I/OpenGLRenderer: Initialized EGL, version 1.4 
    12-17 10:16:09.015 4039-4062/com.otemainc.smartmenu D/OpenGLRenderer: Swap behavior 1 
    12-17 10:16:09.019 4039-4062/com.otemainc.smartmenu D/EGL_emulation: eglCreateContext: 0x8a6bf440: maj 2 min 0 rcv 2 
    12-17 10:16:09.029 4039-4062/com.otemainc.smartmenu D/EGL_emulation: eglMakeCurrent: 0x8a6bf440: ver 2 0 (tinfo 0xa53f3cc0) 
    12-17 10:16:09.053 4039-4062/com.otemainc.smartmenu D/EGL_emulation: eglMakeCurrent: 0x8a6bf440: ver 2 0 (tinfo 0xa53f3cc0) 
    12-17 10:16:09.398 4039-4039/com.otemainc.smartmenu I/AssistStructure: Flattened final assist data: 2788 bytes, containing 1 windows, 9 views 
    12-17 10:16:10.708 4039-4044/com.otemainc.smartmenu I/zygote: Do partial code cache collection, code=28KB, data=26KB 
    12-17 10:16:10.709 4039-4044/com.otemainc.smartmenu I/zygote: After code cache collection, code=28KB, data=26KB 
    12-17 10:16:10.709 4039-4044/com.otemainc.smartmenu I/zygote: Increasing code cache capacity to 128KB 
    12-17 10:16:38.461 4039-4044/com.otemainc.smartmenu I/zygote: Do partial code cache collection, code=48KB, data=49KB 
    12-17 10:16:38.461 4039-4044/com.otemainc.smartmenu I/zygote: After code cache collection, code=48KB, data=49KB 
    12-17 10:16:38.461 4039-4044/com.otemainc.smartmenu I/zygote: Increasing code cache capacity to 256KB 
    12-17 10:18:00.261 4039-4044/com.otemainc.smartmenu I/zygote: Do full code cache collection, code=121KB, data=99KB 
    12-17 10:18:00.262 4039-4044/com.otemainc.smartmenu I/zygote: After code cache collection, code=97KB, data=69KB 
    12-17 10:20:06.115 4039-4044/com.otemainc.smartmenu I/zygote: Do partial code cache collection, code=121KB, data=85KB 
    12-17 10:20:06.115 4039-4044/com.otemainc.smartmenu I/zygote: After code cache collection, code=121KB, data=85KB 
    12-17 10:20:06.115 4039-4044/com.otemainc.smartmenu I/zygote: Increasing code cache capacity to 512KB 
+2

Können Sie Ihren Logcat bitte teilen? – Mureinik

+0

Jetzt erhalten Sie eine Reihe von wilden Vermutungen als Antworten, da das Logcat ist nicht in der Frage enthalten (und Logcat wird Ihnen sagen, was die Ursache für Ihr Problem) – donfuxx

+0

Ich habe es hinzugefügt –

Antwort

1

Versuchen Sie, dies in OnClick Methode zu verwenden:

Intent i = new Intent(LoginActivity.this, RegisterActivity.class); 
startActivity(i); 
finish(); 

Fügen Sie auch RegisterActivity in Manifest-Datei hinzu.

+0

Die Registeraktivität ist da –

Verwandte Themen