android PopupWindow + spinner 後,點擊spinner報錯:Unable to add window

在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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章