PopWindow的使用

方法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的使用

上一篇:2013-6-2 [转载自CSDN]如何入门Windows系统下驱动开发


下一篇:SQLSERVER误删除了Windows登录用户验证方式使用Windows身份验证的解决方法