首页 > Windows开发 > 详细

PopWindow的使用

时间:2014-01-14 21:49:14      阅读:1266      评论:0      收藏:0      [点我收藏+]

方法1:
public PopupWindow pop=null;
public View pop_view;
--------------------
pop_view = getLayoutInflater().inflate(R.layout.list_pop, null,false);
pop= new
PopupWindow(pop_view,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
lv_client_droplist = (ListView) popupWindow_view.findViewById(R.id.lv_client_droplist);

//popupWindow.showAtLocation(findViewById(R.id.parent), Gravity.CENTER| Gravity.CENTER, 0, 0);
--------------------
private void dismissPopupWindow() {
        if (popwindow != null && popwindows.isShowing()) {
             popwindow.dismiss();
             popwindow = null;
        }
}    

@Override
protected void onDestroy() {
       super.onDestroy();
       dismissPopupWindow();
}

------------------------------------------------------------------------------

注意:
pop= new PopupWindow(pop_view,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,true);
可以换为:
pop= new PopupWindow(pop_view,-2,-2,true);
popupWindow.dismiss()方法只能关闭显示的窗口并不能释放内存,所以每show一次内存一直在增加。
-------------------------------------------------------------------------------
方法2:
    private PopupWindow popwindow;
    private View pop_view;
    ---------------
    pop_view.setFocusable(true);  //锁定后面界面
    popwindow = new PopupWindow(pop_view,-2,-2,true);
    popwindow.setAnimationStyle(R.style.PopupAnimation);
    popwindow.setBackgroundDrawable(new BitmapDrawable());
    popwindow.showAtLocation(findViewById(R.id.parent), Gravity.LEFT| Gravity.TOP, 10, 50);
    popwindow.update();

PopWindow的使用

原文:http://www.cnblogs.com/zhangping/p/3513861.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!