何时使用 Android PopupWindow vs Dialog [英] When to use Android PopupWindow vs Dialog

查看:22
本文介绍了何时使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆