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 * ...
随机推荐
- windows下curl报错:curl : (1) Protocol https not supported or disabled in libcurl
如果命令语句中有单引号,改为英文双引号试一下
- C#秘密武器之反射——基础篇
先来一段有用的反射代码 namespace Calculator { public interface Iwel { String Print(); } } namespace Calculator ...
- Python学习笔记(三)多线程的使用
这节记录学习多线程的心得. Python提供了thread模块,不过该模块的缺点很多,例如无法方便的等待线程结束,所以我们使用更加高级的threading模块. threading模块的使用一 ...
- 【Python3 爬虫】07_正则表达式(原子)
原子是正则表达式的最基本的组成单位,而且在每个模式中最少包含一个原子.原子是由所有那些未显示指定为元字符的打印和非打印字符组成. 原子分类 1.普通字符作为原子 普通字符是编写正则表达式时最常见的原子 ...
- LDAP简介及LDAP服务器的安装与配置
一.LDAP简介 全称:Lightweight Directory Access Protocol,目录服务是一种特殊的数据库系统,其专门针对读取. LDAP目录中的信息是按照树型结构组织,具体信息存 ...
- 关于升级 phpStudy 中 MySQL 版本至 5.7.17
mysql版本低于5.6 自动更新时间会报错.因此要升级mysql版本.综合网上资料和实际过程中遇到的问题,具体细节和注意事项如下: 1.从官网上下载高版本的 MySQL :https://dev.m ...
- Matlab、R向量与矩阵操作
Matlab.R向量与矩阵操作 描 述 Matlab R 1 建立行向量v=[1 2 3 4] v=[1 2 3 4] v<-c(1,2,3,4)或v<-scan(),然后输入 ...
- Jquery的promise对象
一直用jquery,ajax一直是这么写: $.ajax({ url: 'abc.com/index', type: 'post', data: { abc:1 }, success: functio ...
- linux中的dd复制命令
dd命令用于复制文件并对原文件的内容进行转换和格式化处理.dd命令功能很强大的,对于一些比较底层的问题,使用dd命令往往可以得到出人意料的效果.用的比较多的还是用dd来备份裸设备.但是不推荐,如果需要 ...
- iOS的isnan函数
假设一个数是一个确定的数.那它就不是nan值 假设一个数是无穷大,无穷小.那它就是nan值 我试着打印了下面的值是不是nan值 if (isnan(1)) { DLog(@"1是NAN&qu ...