- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我花了一段时间试图让它工作,在网上寻找类似的解决方案,但似乎都没有用。我需要我的 PopupWindow 只在点击生成按钮时被关闭,而不是在窗口外点击。以前有人遇到过这个问题吗?
private void LoadRAMSPopup() {
mainLayout.getForeground().setAlpha(150);
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
final View ramsView = layoutInflater.inflate(R.layout.popup_rams, null);
final PopupWindow popupRAMS = new PopupWindow(
ramsView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
if (Build.VERSION.SDK_INT >= 21) {
popupRAMS.setElevation(5.0f);
}
findViewById(R.id.mainLayout).post(new Runnable() {
@Override
public void run() {
popupRAMS.showAtLocation(findViewById(R.id.mainLayout), Gravity.CENTER, 0, 0);
popupRAMS.setOutsideTouchable(false);
popupRAMS.setFocusable(true);
popupRAMS.update();
Button btnGenerate = (Button) ramsView.findViewById(R.id.btnGenerate);
btnGenerate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), CreateRAMSActivity.class);
startActivity(intent);
popupRAMS.dismiss();
mainLayout.getForeground().setAlpha(0);
}
});
}
});
}
最佳答案
设置popupRAMS.setFocusable(false)。删除使弹出窗口消失所需的不必要的触摸。所以请替换
popupRAMS.setFocusable(true);
与
popupRAMS.setFocusable(false);
也尝试添加
popupRAMS.setOutsideTouchable(false);
希望对您有所帮助。
关于Android - 防止在 PopupWindow 之外单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43255773/
我想在另一个 PopUpWindow 中打开一个 PopUpWindow。我的 MainActivity 中有一个 ImageButtons。当我单击它时,会出现一个 PopUpWindow。我在我的
在 Honeycomb 应用程序中,我在多个地方使用 PopupWindow 的自定义子类来显示各种 View 。这一切都很好,直到其中一个 View 碰巧尝试显示另一个 PopupWindow。 例
android PopupWindow 可以显示另一个 PopupWindow 吗?可以同时打开多少个 PopupWindow?只有一个? 第一个PopupWindow正常显示。但是在单击按钮时(在第
在我的应用程序中,我试图将包含 popupwindow 的 View 设置为不可见,并在一段时间后设置为可见。我的弹出窗口包含图像和文本,我希望弹出窗口的整个 View 及其内容根据某种逻辑显示和不显
当从单独的类调用 PopupWindow 方法时,我希望能够从 xml 文件定义 PopupWindow 中的布局。下面的代码根据需要工作,除了布局是从 java 文件而不是 xml 文件中提取的。在
谷歌开发团队的人能解释一下如何避免在 pre-ics 设备上发生这种崩溃吗?在我的例子中,ListView 项目上的 ImageButton 是 PopupWindow 的 anchor ,用于创建下
PopupWindow 膨胀得很好,直到它接近屏幕底部,它被切断了。有谁知道当它接近屏幕底部时如何让它向上膨胀? public SelectBucketMenu(Context context) {
这个问题已经有答案了: Android popup window dismissal (11 个回答) 已关闭 9 年前。 我创建了弹出窗口 public void myPopUp() {
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
有 PopupWindow 的 xml 文件: 如何以编程方式替换此 xml 中的图标和背景? 最佳答案 LinearLayout menuLayout= (LinearLayout) activit
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
我想在向其添加布局之前让 PopupWindow 至少显示一个空矩形。 这不起作用: public void configure() { LinearLayout linearLayout =
我在使用 PopupWindow android 默认小部件时遇到了问题。当我触摸按钮显示弹出窗口而不是按手机上的后退按钮时,在显示弹出窗口之前,我有强制关闭消息,接下来是错误: 10-14
如何将键事件从可聚焦的 PopupWindow 分派(dispatch)到基础 Activity。如果我设置窗口可聚焦,它会消耗所有事件。我希望能够拦截一个 key ,并处理事件。 这是我的困境:我的
我想通过点击窗口外部或按下后退按钮来关闭 PopupWindow。现在你可以点击屏幕上的任何地方,窗口会关闭,我不明白为什么。我还想给 PopupWindow 添加一个阴影。谢谢! 主要 Activi
在我的一个 Activity 中,有一个按钮,单击它会打开一个PopupWindow。我的 Intent 是,当 PopupWindow 打开并且用户单击屏幕上弹出区域以外的任何地方时,应该关闭 Po
目前,我在线性布局中有一个按钮,如下所示: 我还有一个 createPopup 扩展(它确实在单击按钮时执行)。 public void createPopup(View view) {
我有一个用于显示谷歌地图的弹出窗口,但一旦它打开我似乎无法关闭它,我试图设置后退按钮以关闭它但无法调用 onBackButtonClick当我在 fragment 中时覆盖。虽然似乎没有做任何事情
我想像 Google Keep 在创建提醒时那样在虚拟键盘上方显示一个 PopupWindow: 最佳答案 我相信,您正在寻找的是以下组合: popupWindow.setSoftInputMode(
我如何显示和隐藏同一个弹出窗口,而不是每次都创建一个对象。这就是我创建窗口的方式。我不想解雇();并出于性能原因每次重新创建窗口。 popupWindow = new PopupWindow(
我是一名优秀的程序员,十分优秀!