i have implemented onClickListener and the main activity of my app in a separate classes. The main classes contains some buttons and some edittext, and when the user press a cancel button, the edittext hint should be reset. main activity
public ButtonListener(Context cx , Button b, EditText f) {
cntx = cx;
button = b;
et = f;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//check wich button was pressed
if(button.getId() == R.button.button_cancel) {
et.setHint(R.string.et_nome);
}
else {
//operations for other buttons
But it doesn't work. When i press cancel, the edittext it's not erased. In the main activity i've call the button with
Button b = (Button)findViewById(R.button.button_cancel);
and set the listener
b.setOnclickListener(new ButtonListener(this, b, edittext));
what's wrong?