I implemented a custom button and added a task to it with delay so it shows the animation. When I double click it, it crashes. I want to make so it's only clickable once.
i have tried setEnabled(false); i have tried setClickable(false);
i tried a variable that check if a button has been clicked and disables it.
public class Login extends AppCompatActivity {
Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    final SubmitButton LoginBtn = findViewById(R.id.login);
    handler = new Handler();
    LoginBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LoginBtn.setEnabled(false);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    LoginBtn.setEnabled(true);
                    Intent startActivity = new Intent(Login.this, Main_page.class);
                    startActivity(startActivity);
                    finish();
                }
            }, 3200);
        }
    });
}
}
As I wrote, I want that if the button has been clicked that it becomes unclickable.
 
     
    