Android学习之PopupWindow

来源:互联网 发布:php 打印数组格式 编辑:程序博客网 时间:2024/04/29 06:04

好多知识都是项目需要现研究现尝试,由于工期原因,我们好像总是没有时间去深入研究,初次使用总是被一些小问题折腾的很烦躁,在此将使用过程中的遇到的问题记录一下,以便今后遇到相同问题时能尽快解决。

(1)我们在简单使用popupWindow时,发现一切都设置好了,可是PopupWindow就是出不来。

这是因为popupWindow是一定要设置宽高的,否则PopupWindow就不显示。

        ListView mListView  = (ListView)getLayoutInflater().inflate(R.layout.popup_window_layout, null);        mListView.setAdapter(mAdapter);        popupWindow = new PopupWindow(mListView);        popupWindow.setWidth(LayoutParams.WRAP_CONTENT);        popupWindow.setHeight(LayoutParams.WRAP_CONTENT);
(2)PopupWindow焦点问题

PopupWindow默认是不获取焦点的,通过setFocesable(true)可以让其获得焦点,不过注意看文档说明:

public void setFocusable (boolean focusable)

Added in API level 1

Changes the focusability of the popup window. When focusable, the window will grab the focus from the current focused widget if the popup contains a focusable View. By default a popup window is not focusable.

If the popup is showing, calling this method will take effect only the next time the popup is shown or through a manual call to one of the update() methods.

Parameters
focusabletrue if the popup should grab focus, false otherwise.
See Also
  • isFocusable()
  • isShowing()
  • update()
(3)PopupWindow setIgnoreCheekPress() 方法

public void setIgnoreCheekPress ()

Added in API level 1

Set the flag on popup to ignore cheek press eventt; by default this flag is set to false which means the pop wont ignore cheek press dispatch events.

If the popup is showing, calling this method will take effect only the next time the popup is shown or through a manual call to one of the update() methods.

See Also
  • update()
解释说明:http://stackoverflow.com/questions/10840884/what-is-a-cheek-press-event


PopupWindow在设计使用时,遇到问题会很多,看一下下面的文章就知道了。

http://blog.csdn.net/tianxiangshan/article/details/7878490


PopupWindow 精确控制显示位置

http://blog.csdn.net/janronehoo/article/details/8570172

http://www.pocketdigi.com/20130218/987.html

http://www.imyukin.com/?p=233




0 0
原创粉丝点击