什么时候使用Android PopupWindow vs Dialog [英] When to use Android PopupWindow vs Dialog

查看:531
本文介绍了什么时候使用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.

我认为他们每个人都可以做完全相同的另一个,但在两者之间选择是一个方便的程序员关于你想如何使用对象的问题。我不是计算机科学的博士,但我不认为两者之间的处理时间有显着差异,基于我在他们各自的类定义中看到。

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天全站免登陆