When to use Android PopupWindow vs Dialog(何时使用 Android PopupWindow vs Dialog)
问题描述
我不清楚何时使用 PopupWindow 与 Dialog.任何见解将不胜感激.谢谢.
I'm unclear about when to use PopupWindow vs Dialog. Any insight would be much appreciated. Thanks.
推荐答案
它们都使用 addView() 方法以及各种 windowManager 方法.两者在这方面是相似的.
They both use the addView() method along with various windowManager methods. The two are similar in that regard.
对话框似乎带有更多用于交互的内置功能,例如基类中已经包含的处理程序和按钮,而 PopupWindows 带有更多用于在屏幕上定位它们的内置方法.
Dialogs seem to come with more built-in features for interaction, such as handlers and buttons already included in the base class, while PopupWindows come with more built-in methods for positioning them about the screen.
我认为它们中的每一个都可以做与另一个完全相同的事情,但是在两者之间进行选择对于程序员来说是一个方便的问题,即你想如何使用 Object.我不是计算机科学博士,但根据我在各自的类定义中看到的情况,我认为两者的处理时间没有显着差异.
I think that each of them can do exactly the same as the other, but choosing between the two will be a matter of convenience to the programmer with regards to how you want to use the Object. I'm not a phD in computer science, but I do not think there is a significant difference in processing time between the two based on what I saw in their respective class definitions.
我的建议:如果您想更好地控制视图在显示屏上的显示位置,请使用 PopupWindow.如果您想在视图之间添加更多控制和反馈,请使用对话框.如果您像我一样想要对所有内容进行主控制,我建议使用 PopupWindow,因为它具有较少的用户明显的默认方法可以覆盖.
My advice: If you want to have greater control over where your View appears on the display, use a PopupWindow. If you want to add more control and feedback between your View then use a Dialog. If you, like me, want master control over everything, I would suggest a PopupWindow since it has fewer user-evident default methods to override.
这篇关于何时使用 Android PopupWindow vs Dialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:何时使用 Android PopupWindow vs Dialog
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01