46、PopWindow工具类
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> <solid android:color="@color/home_00" /> <corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" /> <stroke
android:width="2dp"
android:color="@color/home_00" /> </shape>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"> <RelativeLayout
android:layout_width="280dp"
android:layout_height="wrap_content"
android:background="@drawable/pop_bg"
android:orientation="vertical"
android:id="@+id/pop_student"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/img_pop_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/student_close"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:layout_alignParentTop="true" /> <LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_head"
android:background="@drawable/student_head_bg"
android:layout_below="@id/img_pop_close"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_centerHorizontal="true">
<com.jtx.iintroduce.widget.CircleImageView
android:id="@+id/img_pop_head"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/home_head"
app:border_width="1dp" />
</LinearLayout> <TextView
android:id="@+id/txt_pop_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/layout_head"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:textSize="20sp"
android:text="张三丰" /> <TextView
android:id="@+id/txt_pop_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txt_pop_name"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textSize="16sp"
android:text="13131313131" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt_pop_phone"
android:gravity="center"
android:background="@drawable/pop_bg_button"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginTop="40dp"> <Button
android:id="@+id/btn_pop_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:textColor="@color/white"
android:textSize="20sp"
android:text="拨打电话"
android:drawablePadding="13dp"
android:drawableLeft="@drawable/student_phone2" />
</LinearLayout> </RelativeLayout>
</RelativeLayout>
public class StudentPopWindow extends PopupWindow implements View.OnClickListener { private View popView = null;
private BaseActivity act = null;
private CircleImageView img_pop_head = null;
private TextView txt_pop_name = null;
private TextView txt_pop_phone = null;
private String strPhone = null; public StudentPopWindow(BaseActivity act, String head, String name, String phone) {
super(act);
LayoutInflater inflater = (LayoutInflater) act
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
popView = inflater.inflate(R.layout.pop_student, null); this.act = act;
strPhone = phone;
popView.findViewById(R.id.btn_pop_call).setOnClickListener(this);
popView.findViewById(R.id.img_pop_close).setOnClickListener(this); img_pop_head = (CircleImageView) popView.findViewById(R.id.img_pop_head);
txt_pop_name = (TextView) popView.findViewById(R.id.txt_pop_name);
txt_pop_phone = (TextView) popView.findViewById(R.id.txt_pop_phone);
act.mToolBitmap.display(img_pop_head, head);
txt_pop_name.setText(name);
txt_pop_phone.setText(phone); //设置SelectPicPopupWindow的View
this.setContentView(popView);
//设置SelectPicPopupWindow弹出窗体的宽
this.setWidth(LayoutParams.MATCH_PARENT);
//设置SelectPicPopupWindow弹出窗体的高
this.setHeight(LayoutParams.MATCH_PARENT);
//设置SelectPicPopupWindow弹出窗体可点击
this.setFocusable(true); //设置SelectPicPopupWindow弹出窗体动画效果
//this.setAnimationStyle(R.style.AnimBottom);
//实例化一个ColorDrawable颜色为半透明
ColorDrawable dw = new ColorDrawable(act.getResources().getColor(R.color.b_translucent));
//设置SelectPicPopupWindow弹出窗体的背景
this.setBackgroundDrawable(dw); //mMenuView添加OnTouchListener监听判断获取触屏位置如果在选择框外面则销毁弹出框
/*popView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int height = popView.findViewById(R.id.pop_student).getTop();
int y=(int) event.getY();
if (event.getAction() == MotionEvent.ACTION_UP) {
if (y < height) {
dismissPop();
}
}
return true;
}
});*/ } @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.img_pop_close:
dismissPop();
break;
case R.id.btn_pop_call:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel://" + strPhone));
act.startActivity(intent);
break;
}
} private void dismissPop() {
popView = null;
act = null;
img_pop_head = null;
txt_pop_name = null;
txt_pop_phone = null;
strPhone = null;
dismiss();
}
}
String strHead = listData.get(position).photo;
String strName = listData.get(position).name;
String strPhone = listData.get(position).phone; popWindow = new StudentPopWindow(mActivity, strHead, strName, strPhone);
popWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
popWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); //显示窗口
//设置layout在PopupWindow中显示的位置
popWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
46、PopWindow工具类的更多相关文章
- Android 工作流提交审批填写审批意见PopWindow工具类
公司的项目中几乎都会有走工作流这个环节,为了提高效率,现在特意把弹出的填写审批意见PopWindow改转成工具类,提高效率,免得下次又得整.先看运行效果.
- Java 集合-Arrays工具类的介绍
2017-10-31 18:39:46 Arrrays工具类:此类包含用来操作数组(比如排序和搜索)的各种方法. 常用方法: 主要是数组的一些常用方法如: asList:将数组转成集合 binaryS ...
- Java常用类归纳(Object、System、Properties、包装类和工具类等等)
Object类 Object 是类层次结构的根类.每个类都使用 Object 作为超类,所有对象(包括数组)都实现这个类的方法.了解Object的方法是很有必要的. protected Object ...
- Android—关于自定义对话框的工具类
开发中有很多地方会用到自定义对话框,为了避免不必要的城府代码,在此总结出一个工具类. 弹出对话框的地方很多,但是都大同小异,不同无非就是提示内容或者图片不同,下面这个类是将提示内容和图片放到了自定义函 ...
- [转]Java常用工具类集合
转自:http://blog.csdn.net/justdb/article/details/8653166 数据库连接工具类——仅仅获得连接对象 ConnDB.java package com.ut ...
- .net使用正则表达式校验、匹配字符工具类
开发程序离不开数据的校验,这里整理了一些数据的校验.匹配的方法: /// <summary> /// 字符(串)验证.匹配工具类 /// </summary> public c ...
- Android 系统工具类SystemUtils
包含的功能有: 获取系统中所有APP应用.获取用户安装的APP应用.根据包名和Activity启动类查询应用信息.跳转到WIFI设置.WIFI网络开关.移动网络开关.GPS开关 当前若关则打开 当前若 ...
- App开发流程之加密工具类
科技优家 2016-09-08 18:10 从这篇记录开始,记录的都算是干货了,都是一些编程日常的积累. 我建议先将基础的工具加入项目,后续的开发效率会呈指数增长.如果在专注功能开发过程中,才发现缺少 ...
- Json与javaBean之间的转换工具类
/** * Json与javaBean之间的转换工具类 * * {@code 现使用json-lib组件实现 * 需要 * json-lib-2.4-jdk15.jar * ...
随机推荐
- junit4单元測试总结
junit4单元測试总结 本文开发环境为myeclipse10.7 1. 准备工作 1.1. 选择须要单元測试的文件 创建mavenproject.右击须要单元測试的文件,选择New->oth ...
- 恼人的The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved...错误,无奈用Struts的bean:write替代了JSTL的C:out
一个应用中有两个页面使用了JSTL的c:out输出,就类似这么简单三句 <c:if test="${!empty error}"> <h2>&l ...
- System.getProperty("line.separator")
转自:http://blog.sina.com.cn/s/blog_707577700100nv74.html 标题所写的代码能获得当前系统的换行符. 不要随便用 \n\r \n \r,因 ...
- Mycat探索之旅(4)----Mycat的自增长主键和返回生成主键ID的实现
说明:MyCAT自增长主键和返回生成主键ID的实现 1) mysql本身对非自增长主键,使用last_insert_id()是不会返回结果的,只会返回0:这里做一个简单的测试 创建测试表 ------ ...
- win10系统怎样手动安装cab更新补丁
win10系统怎样手动安装cab更新补丁 1. 把所有补丁放进一个文件夹 例如 C:\UPDATE2. 以管理员运行命令提示符 3. 输入以下命令後按 Enterdism /online /add-p ...
- 【BIEE】16_饼图应用
在BIEE中,我们可以使用饼图来展示报表数据 饼图在使用中有三元素:①切片 ②饼图 ③度量 那么我们来分别看下这三个元素的功能分别是什么? 我们通过上图可以看出度量中存在2个度量,那么此时的饼图数量是 ...
- ibatis常用的集中判断语句
http://blog.csdn.net/liaomin416100569/article/details/5344483
- VMware12.0下安装CentOS-6.9-x86_64-bin-DVD.iso
使用的是vmware workstation 12 pro 创建虚拟机 注意上面的 安装程序光盘镜象文件(iso)(M): 是我之前配置,现在可以不做任何处理 此处使用的是centos的64位 在创建 ...
- nginx 404重定向到自定义页面
在访问时遇到上面这样的404错误页面,我想99%(未经调查,估计数据)的用户会把页面关掉,用户就这样悄悄的流失了.如果此时能有一个漂亮的页面能够引导用户去他想去的地方必然可以留住用户.因此,每一个网站 ...
- 利用python批量缩放图片
废话少说,上代码: import matplotlib as mpl mpl.use('Agg') import os import matplotlib.pyplot as plt from sci ...