[Solved] There is no error in the code but the button doesn’t perform any action


Try to move the following lines out of the OnClickListener, they should be in the onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
    //...
    inputUsername = findViewById(R.id.inputUsername);
    inputEmail = findViewById(R.id.inputEmail);
    inputPassword = findViewById(R.id.inputPassword);
    inputCpassword = findViewById(R.id.inputCpassword);
    btnRegister = findViewById(R.id.btnRegister);
    btnRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
               validations();
        }
    });
    // ...
}

2

solved There is no error in the code but the button doesn’t perform any action