自定义加载 PopupWindow
来源:互联网 发布:美工学习 编辑:程序博客网 时间:2024/06/16 05:42
public class PersonalDetailPopupWindow implements View.OnClickListener {
private Context mContext;
private PopupWindow mPopupWindow;
private View mPersonalDetail;
public PopupWindow showPersonalDetail(Context context, GetVisitorNosBean bean) { mContext = context; if (mPopupWindow == null) { mPopupWindow = new PopupWindow(context, null, android.R.style.Widget_DeviceDefault_PopupWindow); mPersonalDetail = LayoutInflater.from(context).inflate(R.layout.personal_detail, null); // mPopupWindow.setContentView(mPersonalDetail); //初始化控件 initView(mPersonalDetail); //个人详情 // TODO: 2017/7/10 PersonalWithGoods(bean); // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int dialogwidth = windowManager.getDefaultDisplay().getWidth(); int dialogheight = windowManager.getDefaultDisplay().getHeight(); mPopupWindow.setHeight(dialogheight * 2 / 3); mPopupWindow.setWidth(dialogwidth * 2 / 3); //注意这三个属性必须同时设置,不然不能disMiss mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //设置popupwindow的拦截事件 mPopupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { SettingTransparent();//设置背景透明 return false;//这里不拦截 } }); } //设置背景半透明 WindowManager.LayoutParams lp = ((CheckActivity) context).getWindow().getAttributes(); lp.alpha = 0.8f; ((CheckActivity) context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); ((CheckActivity) context).getWindow().setAttributes(lp); // mPopupWindow.showAtLocation(mPersonalDetail, Gravity.CENTER, 0, 0); return mPopupWindow;}//个人详情private void PersonalWithGoods(GetVisitorNosBean bean) { tv_show_visit_people.setText(bean.VisitorName); tv_surveyed_people.setText(bean.UserName); edt_reason.setText(bean.Matter); tv_come_time.setText(bean.VisitingTime); tv_show_follow_up_people.setText(""); tv_show_goods.setText("");}private TextView tv_show_visit_people;private TextView tv_visit_people_detaile;private TextView tv_surveyed_people;private TextView tv_surveyed_people_detaile;private EditText edt_reason;private TextView tv_come_time;private TextView tv_show_follow_up_people;private TextView tv_look_follow_up_people_detail;private TextView tv_show_goods;private void initView(View personal_detail) { tv_show_visit_people = (TextView) personal_detail.findViewById(R.id.tv_show_visit_people); tv_visit_people_detaile = (TextView) personal_detail.findViewById(R.id.tv_visit_people_detaile); tv_surveyed_people = (TextView) personal_detail.findViewById(R.id.tv_surveyed_people); tv_surveyed_people_detaile = (TextView) personal_detail.findViewById(R.id.tv_surveyed_people_detaile); edt_reason = (EditText) personal_detail.findViewById(R.id.edt_reason); edt_reason.setFocusable(false);//设置不能获取焦点 tv_come_time = (TextView) personal_detail.findViewById(R.id.tv_come_time); tv_come_time.setFocusable(false); tv_show_follow_up_people = (TextView) personal_detail.findViewById(R.id.tv_show_follow_up_people); tv_look_follow_up_people_detail = (TextView) personal_detail.findViewById(R.id.tv_look_follow_up_people_detail); tv_show_goods = (TextView) personal_detail.findViewById(R.id.tv_show_goods); tv_show_goods.setFocusable(false); //来访人的详情的点击事件 tv_visit_people_detaile.setOnClickListener(this); //被访人的详情点击事件 tv_surveyed_people_detaile.setOnClickListener(this); //随访人的详细信息 tv_look_follow_up_people_detail.setOnClickListener(this);}@Overridepublic void onClick(View v) { //设置透明 SettingTransparent(); switch (v.getId()) { case R.id.tv_visit_people_detaile: //来访人的详情的点击事件 Intent intent = new Intent(mContext, VisitPeopleActivity.class); mContext.startActivity(intent); mPopupWindow.dismiss(); break; case R.id.tv_surveyed_people_detaile: //被访人的详情点击事件 Intent intent2 = new Intent(mContext, SurveyedPeopleActivity.class); mContext.startActivity(intent2); mPopupWindow.dismiss(); break; case R.id.tv_look_follow_up_people_detail: //随访人的详细信息 Intent intent3 = new Intent(mContext, FollowUpPeopleActivity.class); mContext.startActivity(intent3); mPopupWindow.dismiss(); break; }}//设置透明private void SettingTransparent() { WindowManager.LayoutParams lp = ((CheckActivity) mContext).getWindow().getAttributes(); lp.alpha = 1f; ((CheckActivity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); ((CheckActivity) mContext).getWindow().setAttributes(lp);}
}
阅读全文
0 0
- 自定义加载 PopupWindow
- 自定义PopupWindow
- 自定义popupWindow
- 自定义PopupWindow
- 自定义PopupWindow
- PopupWindow自定义
- 自定义popupWindow
- popupwindow进阶--自定义menu
- 自定义PopupWindow动画效果
- android 自定义PopupWindow
- 自定义popupWindow显示位置
- android自定义一个PopupWindow
- PopupWindow自定义位置显示
- Android-自定义PopupWindow
- Android-自定义PopupWindow
- 5、Android-自定义PopupWindow
- 自定义控件----popupWindow
- 自定义PopupWindow+BaseAdapter+Anim
- 排序算法小结
- Python中is和==的具体解释
- Roads in the North POJ
- hdoj 5974 A Simple Math Problem
- SVN的安装与常用功能使用以及解决安装配置过程中的一些错误
- 自定义加载 PopupWindow
- Java面试笔试指南(三)---关键字
- 优化
- Tarjan算法 计算有向图的强连通量(可作为模板)-------CCF CSP 高速公路
- memset函数详解
- (十九)ListView 复用思想
- C++中二维数组的动态申请内存
- oracle 中merage Into的使用
- 洛谷 P1231 教辅的组成