PopupWindow-----listview item的点击出现PopupWindow
/**
* 设置listview item的点击事件
*/
lv_app_manager.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if (position == 0) {
return;
} else if (position == (userAppInfos.size() + 1)) { //超过不弹出
return;
} else if (position <= userAppInfos.size()) {// 用户程序
int newposition = position - 1;
appInfo = userAppInfos.get(newposition); //appInfo单个对象
} else {// 系统程序
int newposition = position - 1 - userAppInfos.size() - 1;
appInfo = systemAppInfos.get(newposition); // 点击
}
// System.out.println(appInfo.getPackname());
dismissPopupWindow();
View contentView = View.inflate(getApplicationContext(),
R.layout.popup_app_item, null);
ll_start = (LinearLayout) contentView
.findViewById(R.id.ll_start);
ll_share = (LinearLayout) contentView
.findViewById(R.id.ll_share);
ll_uninstall = (LinearLayout) contentView
.findViewById(R.id.ll_uninstall); //卸载 ll_start.setOnClickListener(AppManagerActivity.this);
ll_share.setOnClickListener(AppManagerActivity.this);
ll_uninstall.setOnClickListener(AppManagerActivity.this);
// 得到 PopupWindow 的对象
popupWindow = new PopupWindow(contentView, -2, -2); // 上面的contentView
// 动画效果的播放必须要求窗体有背景颜色。
// 透明颜色也是颜色
popupWindow.setBackgroundDrawable(new ColorDrawable(
Color.TRANSPARENT));
int[] location = new int[2];
view.getLocationInWindow(location);
// 在代码里面设置的宽高值 都是像素。---》dip
int dip = 60;
int px = DensityUtil.dip2px(getApplicationContext(), dip);
System.out.println("px=" + px); // 得到 px
popupWindow.showAtLocation(parent, Gravity.LEFT | Gravity.TOP,
px, location[1]);
// 最后加上动画
ScaleAnimation sa = new ScaleAnimation(0.3f, 1.0f, 0.3f, 1.0f,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0.5f);
sa.setDuration(300);
AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
aa.setDuration(300);
AnimationSet set = new AnimationSet(false);
set.addAnimation(aa);
set.addAnimation(sa);
contentView.startAnimation(set);
}
}); 1.关闭的方法 private void dismissPopupWindow() {
// 把旧的弹出窗体关闭掉。
if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
popupWindow = null;
}
}
PopupWindow-----listview item的点击出现PopupWindow的更多相关文章
- 取消GridView/ListView item被点击时的效果 记录学习
方法一,在控件被初始化的时候设置 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelector(ne ...
- 取消GridView/ListView item被点击时的效果
方法一,在控件被初始化的时候设置 ? 1 2 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelec ...
- Android-取消GridView/ListView item被点击时的效果
方法一,在控件被初始化的时候设置 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelector(ne ...
- ListView(4)取消GridView/ListView item被点击时的效果
方法一,在代码中设置 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelector(new Colo ...
- PopupWindow+ListView+OnItemClick点击无效
昨天踩了个大坑,从下午折腾到现在.实现以下功能: popupWindow显示listview,listView OnItemClick点击后获取值. 由于重写listview 是有两部分 列表正文和右 ...
- PopupWindow+ListView
1. 获取打到数据 for (int i = 0; i < iocOutMakeMaterialSubmit.data.size(); i++) { dataListPopupWindow.ad ...
- listview指定某item的点击效果
需求:listview的某些item能够点击,需要点击效果,有些item不能点击,需要屏蔽点击效果. 实现: 1.layout: <ListView android:id="@+id/ ...
- Android点击View显示PopupWindow,再次重复点击View关闭PopupWindow
Android点击View显示PopupWindow,再次重复点击View关闭PopupWindow 这本身是一个看似很简单的问题,但是如果设置不当,就可能导致莫名其妙失效问题.通常在Andro ...
- ListView的Item被点击和其中的Button被点击同时生效
Android开发中在ListView中经常有Button或ImageButton等需要被点击的控件,如果不加一些特殊的限制,有可能 ListView的Item的点击事件或Button的点击事件,其中 ...
随机推荐
- IOS int NSInteger NSNumber区分
1.NSNumber 是一个类继承于NSValue 即一个基本数据类型的集合 包括char a signed or unsigned char, short int, int, long int, l ...
- path.join()和path.resolve()区别
一.区别 1.path.join() 方法使用平台特定的分隔符作为定界符将所有给定的 path 片段连接在一起,然后规范化生成的路径. 2.path.resolve() 方法将路径或路径片段的序列解析 ...
- php 实现简单抽奖
首先有一组数据,里面有中奖的物品和概率 $base_data = [ ['name'=>'特等奖','num'=>1], ['name'=>'一等奖','num'=>5], [ ...
- Python 3 面向对象进阶
Python 3 面向对象进阶 一. isinstance(obj,cls)和issubclass(sub,super) isinstance(obj,cls)检查是否obj是否是类 cls 的 ...
- LINQ 学习路程 -- 查询操作 where
1.where Filtering Operators Description Where Returns values from the collection based on a predicat ...
- 1.SVN
1.SVN安装 SVN服务器端VisualSVN Server(64位OS必须装64位VisualSVN-Server,默认端口是443). 就像建立数据库一样,需要先在svn服务器VisualSVN ...
- QT MVC 模型/视图
1. 模型视图实例一, QFileSystemModel QTreeView ,model/view示例. #include <QApplication> #include <QF ...
- hadoop启动时解决权限问题
解决以上问题,使用命令:sudo chown -hR jxh-ubuntu /usr/local/hadoop
- hash算法打散存储文件
1.首先,为防止一个目录下面出现太多文件,所以使用hash算法打散存储 举例代码: int hashcode = filename.hashCode();//得到hashCode int dir1 = ...
- jenkins-小知识点
如果想停止jenkins运行 控制面板-服务-查看本地服务-选中jenkins 1.启动类型改为手动 2.改为禁止 使用的时候,每次都改一下状态