android.view.WindowManager$BadTokenException: Unable to add window -- token null for displayid = 0
在设置dialog的时候出现android.view.WindowManager$BadTokenException:Unabletoaddwindow--tokennullfordisplayid=0isnotvalid;isyouractivityrunning?这个错误,代码如下所示ProgressDialog progressDialog= DialogUtil.showProgressD
·
在设置dialog的时候出现
android.view.WindowManager$BadTokenException: Unable to add window -- token null for displayid = 0 is not valid; is your activity running?这个错误,代码如下所示
ProgressDialog progressDialog= DialogUtil.showProgressDialog(getApplicationContext(),"提示","对于已履行的无效合同的诉讼时效即无效合同是否受到诉讼时效约束?");
public static ProgressDialog showProgressDialog(Context context, String title, String message) { ProgressDialog dialog = ProgressDialog.show(context, title, message); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(true); dialog.show(); return dialog; }
问题出在Dialog的context不能传入getApplicationContext(),它要依赖于activity。所以这里面直接把getApplicationContext()改成this,如下所示ProgressDialog progressDialog= DialogUtil.showProgressDialog(this,"提示","对于已履行的无效合同的诉讼时效即无效合同是否受到诉讼时效约束?");
更多推荐
已为社区贡献4条内容
所有评论(0)