Is there a way to reset the OnClickListener to its default Android implementation?

Viewed 1485

I have an editText to which I have set an OnClickListener, which is set to open a Dialog. But I have an option in the Dialog to let the user enter data into the editText by manually typing. I tried calling setOnClickListener(null), but it makes the editText unresponsive.

As of yet I have tried a lot of things, but the only thing that works is recreating the activity by calling recreate(), but I'd rather the user not know that I'm recreating the Activity. How do I reset the editText to behave normally like an Android editText works? (like opening the keyboard and entering data on tapping it)

3 Answers

To reset the OnClickListener of an EditText I tried:

View.OnClickListener defaultOnClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        v.requestFocus();
    }
};

...

editText.setOnClickListener(defaultOnClickListener);

and it seems to work fine!

Related