I
I
igorpowers2020-11-22 23:03:21
android studio
igorpowers, 2020-11-22 23:03:21

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

1 answer(s)
O
Oleg, 2020-11-23
@igorpowers

https://stackoverflow.com/questions/5582702/disable...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question