Exception when try to setError() in an editText inside a Popup Window

This is my code:

 if(textNomeGiocatore.getText().toString().equals("")){
                InputMethodManager imm = (InputMethodManager)getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(textNomeGiocatore.getWindowToken(), 0);

                textNomeGiocatore.setError("Nome giocatore necessario");





            }

I have an error in the row :

 textNomeGiocatore.setError("Nome giocatore necessario");

this is the error :

 android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@426940a8 is not valid; is your activity running?

I try to post delayed the error message without resoult.

Someone Can help me?


Source: android

Leave a Reply