草庐IT

PopUpWindow

全部标签

android - EditText setError 在 PopupWindow 中不起作用

我有一个带有自定义布局的弹出窗口,其中有edittext。我正在尝试使用setError方法在edittext中显示错误消息,但它给出了以下异常。android.view.WindowManager$BadTokenException:Unabletoaddwindow--tokenandroid.view.ViewRootImpl$W@211ffd68isnotvalid;isyouractivityrunning?atandroid.view.ViewRootImpl.setView(ViewRootImpl.java:579)atandroid.view.WindowManage

android - PopupWindow.getContentView().getLayoutParams() 在 Android Marshmallow 中返回一个不同的类

我有如下代码。....PopupWindowpopupWindow=newPopupWindow(someView);finalWindowManager.LayoutParamslayoutParams=(WindowManager.LayoutParams)popupWindow.getContentView().getLayoutParams();....问题popupWindow.getContentView().getLayoutParams正在返回不同的类,因为我的类型转换失败了在Marshamallow之前:android.View.WindowManager.Layou

Android popupWindow,无法在弹出窗口中获取元素

我在使用调试器从我的PopupWindow中获取我的Button和其他元素时遇到问题,它只是报告为空?privatevoidinitiatePopupWindow(){try{//WeneedtogettheinstanceoftheLayoutInflaterLayoutInflaterinflater=(LayoutInflater)LoginActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);Viewlayout=inflater.inflate(R.layout.activity_register,(V

android - PopupWindow TouchInterceptor 不工作

我正在尝试测试PopupWindow类。我创建了这个方法来显示弹出窗口:publicvoidshowPopup(){LayoutInflaterlayoutInflater=(LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);ViewpopupView=layoutInflater.inflate(R.layout.popup,null);finalPopupWindowpopup=newPopupWindow(popupView,LayoutParams.WRAP_CONTENT,Lay

android - PopupWindow 内的 WebView 中的上下文菜单/窗口会使应用程序崩溃?

我有一个带有PopupWindow的应用程序,其中包含打开Facebook页面的WebView,任何上下文菜单,例如:WebView中文本字段上的自动完成,甚至应该显示用户复制/粘贴/剪切选项的长按会使应用程序崩溃立即出现以下错误:FATALEXCEPTION:mainandroid.view.WindowManager$BadTokenException:Unabletoaddwindow--tokenandroid.view.ViewRootImpl$W@418cdab0isnotvalid;isyouractivityrunning?atandroid.view.ViewRoot

android - 如何在 PopupWindow 上显示键盘?

我正在使用PopupWindow类,在PopupWindow上我有一个EditText,我的问题是当PopupWindow是可见的,我当时点击EditText软键盘不可见,我无法输入输入。谁能告诉我如何解决这个问题? 最佳答案 当你创建一个新的PopupWindow时,使用另一种构造方法,你必须设置focusable=true;只有View可以聚焦,软键盘才会显示。publicPopupWindow(ViewcontentView,intwidth,intheight,booleanfocusable){}默认的焦点是'false'

java - Activity 在旋转后泄漏了窗口 PopupWindow

当我在显示PopupMenu时旋转我的设备时,我收到了一个WindowLeaked错误。那是我的PopupMenu:privatevoidshowSelectionMenu(Viewcaller){popup=newPopupMenu(this,caller);//popup.getMenuInflater().inflate(R.menu.selection_menu,popup.getMenu());popup.inflate(R.menu.selection_menu);popup.setOnMenuItemClickListener(newPopupMenu.OnMenuIte

android - 如何从输入法服务启动 PopupWindow 或 Dialog?

当我尝试从InputMethodService中弹出PopupWindow(或Dialog)时出现同样的异常:FATALEXCEPTION:mainandroid.view.WindowManager$BadTokenException:Unabletoaddwindow--tokennullisnotvalid;isyouractivityrunning?atandroid.view.ViewRoot.setView(ViewRoot.java:505)atandroid.view.WindowManagerImpl.addView(WindowManagerImpl.java:17

android - PopupWindow 如何获得触摸外部事件的通知?

文档指出PopupWindow将在其窗口外发生触摸事件时被通知setOutsideTouchable(booleantouchable)设置为true。弹出窗口是如何通知的?我没有看到像setOnOutsideTouchListener等任何监听器来接收该信息。例子PopupWindowpopup=newPopupWindow();popup.setOutsideTouchable(true);//nowwhat..howtoreceivethosetouchoutsideevents?谢谢。 最佳答案 尝试像下面的代码fragme

android - 在外部单击时如何使用和关闭 PopupWindow?

我目前正在使用PopupWindow设计简单的提示弹出窗口类(class)。在内容之外单击时,我可以关闭弹出窗口。然而,外面的触摸事件被下划线布局消耗了。我如何使用外部触摸,以便在外部单击时我仍然关闭弹出窗口,但没有触摸事件发送到我的PopupWindow下面的布局?当前设置属性:mPopupWindow.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_bg));mPopupWindow.setOutsideTouchable(true); 最佳答案