"Annotations are not allowed here" when using @Click on android studio

Asked

Viewed 63 times

0

I’m starting to use android Annotations now I have the following class

@EActivity(R.layout.activity_login)
public class Login extends AppCompatActivity {

    @ViewById(R.id.senha)
    private EditText senha;

    @ViewById(R.id.usuario)
    private EditText usuario;

    @ViewById(R.id.button)
    private Button entrar;

    @ViewById(R.id.esqueceu_senha)
    private TextView esqueceu_senha;


    @Click(R.id.esqueceu_senha){
        void onClick(){
            Intent intent = new Intent(this, EsqueceuSenha.class);
            startActivity(intent);
        }
    }
}

I’m getting an android error in the click event with the message "Annotations are not allowed here". Any idea what the error might be?

1 answer

2


There’s a key left on this @Click, try it like this:

@EActivity(R.layout.activity_login)
public class Login extends AppCompatActivity {

    @ViewById(R.id.senha)
    private EditText senha;

    @ViewById(R.id.usuario)
    private EditText usuario;

    @ViewById(R.id.button)
    private Button entrar;

    @ViewById(R.id.esqueceu_senha)
    private TextView esqueceu_senha;


    @Click(R.id.esqueceu_senha)//retirei a que estava aqui
        void onClick(){
            Intent intent = new Intent(this, EsqueceuSenha.class);
            startActivity(intent);
        }
       // e essa
}

Source: https://github.com/androidannotations/androidannotations/wiki/ClickEvents

Examples of documentation:

@Click(R.id.myButton)
void myButtonWasClicked() {
    [...]
}

@Click
void anotherButton() {
    [...]
}

@Click
void yetAnotherButton(View clickedView) {
    [...]
}

@Click({R.id.myButton, R.id.myOtherButton})
void handlesTwoButtons() {
    [...]
}
  • 1

    Solved!! Errinho beast... Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.