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