Answer the question
In order to leave comments, you need to log in
Why is the variable grayed out?
Hello, I'm trying to remove focus from edittext, but new View.OnFocusChangeListener () is grayed out and I can't do anything, but the whole essence does not work, the focus is not removed. What could be the problem? here is the code and screenshot https://i.imgur.com/Jxjmloe.png
inputText = findViewById(R.id.inputText);
inputText.setOnFocusChangeListener (new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question