在android上使用PopupWindow + spinner 做地址选择界面,在点击spinner后,会报错:android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@42617bc8 is not valid; is your activity running?
这个问题找了很久,网上多是说因为content的activity上下文找不到导致,我试了没有解决问题,在一个国外的论坛中看到了解决方法,在spinner的xml中添加一个属性:android:spinnerMode="dialog",这样就不会报错了。
国外网站链接:http://stackoverflow.com/questions/13709741/clicking-spinner-within-popup-window-causes-windowmanagerbadtokenexception
转载自:http://www.360doc.com/content/15/0430/15/8251840_467065939.shtml