簡體   English   中英

當我第二次按下按鈕時,應用程序停止工作

[英]When I press second time on the button , the app stops working

我正在開發一個由 login-register app 組成的應用程序。 在我的登錄活動中,我有 2 個按鈕:登錄和注冊。注冊按鈕用於將您從登錄活動重定向到注冊活動。 該應用程序運行良好,直到我再次按下 。 該應用程序停止工作。


final Button button = (Button) findViewById (R.id.button);
button.setOnClickListener (new View.OnClickListener(){
        @Override
        public void onClick (View v){
            Intent launchactivity = new Intent (Login.this,Register.class);
            startActivity (launchactivity);
        });

嘗試從 Login.This 更改為 getApplicationContext()

public void onClick (View v){
   Intent launchactivity = new Intent (getApplicationContext(),Register.class);
   startActivity (launchactivity);
});

刪除您 login.this 並添加getApplicationContext()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM