android弹出popupwindow时使下层页面变灰色

点击弹出popupwindow代码:

[java]  view plain  copy
  1. findViewById(R.id.btn).setOnClickListener(new OnClickListener() {  
  2.               
  3.             @Override  
  4.             public void onClick(View arg0) {  
  5.                 // TODO Auto-generated method stub  
  6.                 lp=getWindow().getAttributes();  
  7.                 lp.alpha=0.3f;  
  8.                 getWindow().setAttributes(lp);  
  9.                   
  10.                 sharepopup=new ShareSelectPopupWindow(MainActivity.this,shareitemonClick);  
  11.                 sharepopup.setOnDismissListener(touchoutsidedismiss);  
  12.                 sharepopup.showAtLocation(findViewById(R.id.shopdetailparent), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 00);  
  13.             }  
  14.         });  

点击外层消失的代码:

[java]  view plain  copy
  1. public OnDismissListener touchoutsidedismiss=new OnDismissListener(){  
  2.   
  3.         @Override  
  4.         public void onDismiss() {  
  5.             // TODO Auto-generated method stub  
  6.           lp.alpha=1.0f;  
  7.           getWindow().setAttributes(lp);  
  8.             
  9.         }  
  10.     };  

你可能感兴趣的:(★Android基础★)