問題描述
我不清楚何時使用 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!