1
我試圖打開彈出框內的微調框,但當我點擊它時什麼也沒有發生。彈出框內彈出框不打開
private void showTwitterPopUp()
{
View popUpView = getLayoutInflater().inflate(R.layout.twitter_popup, null);
mpopup = new PopupWindow(MainActivity.this);
mpopup.setWidth(this.getWindowManager().getDefaultDisplay().getWidth());
mpopup.setHeight(this.getWindowManager().getDefaultDisplay().getHeight()/2);
mpopup.setContentView(popUpView);
mpopup.setAnimationStyle(android.R.style.Animation_Dialog);
mpopup.setFocusable(true);
mpopup.showAtLocation(popUpView, Gravity.CENTER, 200, 200);
mpopup.setBackgroundDrawable(new BitmapDrawable());
mpopup.setOutsideTouchable(true);
account = (Button) popUpView.findViewById(R.id.button_create_account);
bday = (Button) popUpView.findViewById(R.id.button_birthday);
email = (EditText)popUpView.findViewById(R.id.edittext_email);
sex = (Spinner) popUpView.findViewById(R.id.spinner_sex);
cancel = (Button) popUpView.findViewById(R.id.button_cancel);
ArrayAdapter<CharSequence> adapter1 = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_spinner_item , AppConstants.SEX);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sex.setAdapter(new CustomSpinnerAdapter(adapter1,getString(R.string.sex),this));
}
上單擊微調,然後解僱窗口給予例外。
07-16 13:07:35.434: E/AndroidRuntime(23444): java.lang.IllegalStateException: Calling with view [email protected] but the ViewAncestor is attached to null
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:396)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.WindowManagerImpl$CompatModeWrapper.removeViewImmediate(WindowManagerImpl.java:174)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.widget.PopupWindow.dismiss(PopupWindow.java:1256)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.widget.ListPopupWindow.dismiss(ListPopupWindow.java:612)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.widget.Spinner.onDetachedFromWindow(Spinner.java:411)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.View.dispatchDetachedFromWindow(View.java:11815)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2534)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2532)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2532)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2532)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2532)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2640)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewRootImpl.doDie(ViewRootImpl.java:3993)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.ViewRootImpl.die(ViewRootImpl.java:3976)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:390)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.WindowManagerImpl$CompatModeWrapper.removeViewImmediate(WindowManagerImpl.java:174)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.widget.PopupWindow.dismiss(PopupWindow.java:1256)
07-16 13:07:35.434: E/AndroidRuntime(23444): at com.incbit.mygivingbook.MainActivity.onClick(MainActivity.java:235)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.View.performClick(View.java:4110)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.view.View$PerformClick.run(View.java:17001)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.os.Handler.handleCallback(Handler.java:615)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.os.Handler.dispatchMessage(Handler.java:92)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.os.Looper.loop(Looper.java:137)
07-16 13:07:35.434: E/AndroidRuntime(23444): at android.app.ActivityThread.main(ActivityThread.java:4854)
07-16 13:07:35.434: E/AndroidRuntime(23444): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 13:07:35.434: E/AndroidRuntime(23444): at java.lang.reflect.Method.invoke(Method.java:511)
07-16 13:07:35.434: E/AndroidRuntime(23444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-16 13:07:35.434: E/AndroidRuntime(23444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-16 13:07:35.434: E/AndroidRuntime(23444): at dalvik.system.NativeStart.main(Native Method)
'showAtLocation()得到getWindowToken()令牌'視圖採取不活動的參考。 – Mihir
你是對的,增加了一個你的觀點在哪裏的例子。這將是您活動的頂級視圖,例如的LinearLayout – CodingIntrigue