2015-12-29 55 views
-1

我有弹出窗口。弹出窗口内有editext。当点击button弹出的窗口内检查editext空,并设置错误的editext而在错误editext触摸时收到此错误Editext验证弹出

android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running? 

如何解决这个问题?

+0

无码,我们不禁 – kId

+0

是您的活动的验证运行之前被销毁? – ajantha

+0

我在代码中添加了我的代码,而我触摸edittext seterror得到了上述错误。 – Sarvan

回答

0

在显示PopupWindow之前检查Activity状态。使用下面的代码:

if (!isFinishing()) { 
    // Do yout stuffs here... 
} 

希望这会有所帮助。

0

使用此代码

 AlertDialog.Builder alert = new AlertDialog.Builder(this); 
    alert.setTitle("Reset Password"); 
    alert.setMessage("Please enter the e-mail address for your account."); 
    final EditText email = new EditText(this); 
    LinearLayout lay = new LinearLayout(this); 
    lay.setOrientation(LinearLayout.VERTICAL); 
    email.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); 
    lay.addView(email); 
    alert.setView(lay); 

    alert.setPositiveButton("Ok", 
      new DialogInterface.OnClickListener() { 

       @Override 
       public void onClick(DialogInterface dialog, int which) { 
}