I am developing an android keyboard with a search box inside it. I can detect when the user press my search box and then commit the text he types to my search box.
The problem is that I can't manage to detect when the user is pressing the original EditText (the one that opened the keyboard) because it's not my view.
This is how basically the keyboard looks like:
The keyboard is surrounded by the blue square, and my edit text is surrounded by the red square.
I tried setting this listener on my editText but with no luck: (source)
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
Toast.makeText(getApplicationContext(), "Got the focus", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Lost the focus", Toast.LENGTH_LONG).show();
}
}
});
The listener isn't being called when I press on the other editText. Probably because it is not a part of my service.
Even if I could some how detect a click on screen that is outside of my service layout, it would be great.
Thanks for any help!