标签:
一、概述:
//给条目添加点击监听
lv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
dismissPw();
contentView = View.inflate(AppManger_Activity.this,R.layout.app_manager_popupwindow,null);
pw = new PopupWindow(contentView,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
pw.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
int[] location = new int[2];
//得到contentView在显示的位置
view.getLocationInWindow(location);
//指定显示在父控件的那个位置
pw.showAtLocation(parent, Gravity.LEFT+Gravity.TOP, 60,location[1] );
}
});
/**
* 将popupWindow关闭
*/
private void dismissPw() {
if(pw!=null&&pw.isShowing()){
pw.dismiss();
pw=null;
}
}
标签:
原文地址:http://www.cnblogs.com/candledragle/p/7ab395a82ab0f074175bca5235372d81.html