Android学习之PopupWindow

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

(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
focusable true if the popup should grab focus, false otherwise.
(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
解释说明: 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




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值