基类中的popwindow 再次封装
来源:互联网 发布:java二分查找 编辑:程序博客网 时间:2024/06/05 10:56
鉴于上一篇博客 为了灵活使用,在上一篇的基础上,再做一些封装
1.具体的封装如下:
/**封装的popwindow 弹框 * 1.showlocation 类型 * 2.动画效果 从下往上 * 3.布局不确定 * 4.背景透明可以传参 * 5.弹出动画可以传参 * 6.宽高 可以传参 * */public void showPopListCommon(TextView textView,int Resid,int listviewid,int width,int height,int animationStyle,float bg) { if (sfPopupWindow != null && sfPopupWindow.isShowing()) { sfPopupWindow.dismiss(); backgroundAlpha(1f); } else { popView = LayoutInflater.from(this).inflate(Resid, null);//加载popwindow的布局 ListView listViewSort = (ListView) popView.findViewById(listviewid); setPopListView(listViewSort);//listview的配置 包含点击事件 listViewSort.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (sfPopupWindow != null && sfPopupWindow.isShowing()) { sfPopupWindow.dismiss(); backgroundAlpha(1f); } setPopListViewItemData(i); } }); //设置弹出popupWindow的宽高 sfPopupWindow = new SFPopupWindow(this); sfPopupWindow.setContentView(popView); /*int height = getResources().getDisplayMetrics().heightPixels * 1 / 3;*/ sfPopupWindow.setHeight(height);//设置高度 sfPopupWindow.setWidth(width);//设置宽度 sfPopupWindow.setAnimationStyle(animationStyle);//动画效果 R.style.AnimationPreview sfPopupWindow.setOnDismissListener(new poponDismissListener()); backgroundAlpha(bg); sfPopupWindow.update(); sfPopupWindow.setBackgroundDrawable(new BitmapDrawable());//去除黑边 sfPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); sfPopupWindow.setTouchable(true); sfPopupWindow.setOutsideTouchable(true); sfPopupWindow.setFocusable(true); sfPopupWindow.showAtLocation(textView, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); sfPopupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {//点击外部消失 sfPopupWindow.dismiss(); backgroundAlpha(1f); return true; } return false; } }); }}2.如果说 ,有一些通过的类型,如上述所示:
/**封装的popwindow 弹框 * 1.showlocation 类型 * 2.动画效果 从下往上 * 3.宽度占满全屏,高度为屏幕的三分之一 * */public void showPopList(TextView textView) { int height = getResources().getDisplayMetrics().heightPixels * 1 / 3;//高度 int width = ViewGroup.LayoutParams.MATCH_PARENT;//宽度 int animonStyle = R.style.AnimationPreview; //动画效果 float bg = 0.6f;//背景透明度 showPopListCommon(textView, R.layout.pop_menulist_sort, R.id.menulist_sort, width, height, animonStyle, bg);}
3.在其他页面 可以调用 第二个方法 ,去写逻辑操作
阅读全文
0 0
- 基类中的popwindow 再次封装
- Popwindow封装
- PopWindow封装
- 封装popwindow类,实现所有activity共用
- popwindow的封装
- Android 封装popwindow类,实现所有activity共用
- Android 封装popwindow类,实现所有activity共用
- Android中的popWindow
- Android中的popWindow
- 开发中的popwindow
- Android中的PopWindow控件
- ajax的再次封装!
- 再次封装 AFNetworking
- 对API的再次封装
- iOS AFN的再次封装
- BaseAdapter的再次封装使用
- AngularJs中$http再次封装
- ZookeeperClient(基于ZooKeeperNetEx再次封装)
- 文章标题
- 29. 各层如何添加宏控制
- 30. accdet调试日志
- 带你学习H5画布控件的应用
- c++函数重载的条件
- 基类中的popwindow 再次封装
- 搭建Lamp之安装PHP5.6
- linux系统下安装flask准备
- gcc ,vim,gdb
- gradle命令部署项目
- 31. 开机时间慢
- Windows-驱动-解决Thinkpad e470c在Win8.1下WiFi无法连接的问题
- Maven
- 激活office2010出现0x80070190错误解决方法