PopupWindow+ListView
1. 获取打到数据
for (int i = 0; i < iocOutMakeMaterialSubmit.data.size(); i++) {
dataListPopupWindow.add(iocOutMakeMaterialSubmit.data.get(i));
}
initPopupWindow();
2. 初始化
/**
* 创建PopupWindow
*/
protected void initPopupWindow() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
View contentView = inflater.inflate(R.layout.popupwindow_ioc_out_make_material_submit, null);
ListView listView = (ListView) contentView.findViewById(R.id.list_view_submit_popwin);
adapterPopupwindow = new AdapterPopupWindow(getActivity(), R.layout.item_list_ioc_out_make_material_submit, dataListPopupWindow);
listView.setAdapter(adapterPopupwindow);
//item 的点击事件
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
IOCOutMakeMaterialSubmit.Data data = dataListPopupWindow.get(i);
dataList.add(data);
adapterListView.notifyDataSetChanged();
closePopupWindow();
reset();
}
});
// PopupWindow实例化
popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, true);
popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
// 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
popupWindow.showAtLocation(submitBtn, Gravity.CENTER, 0, 0);
//获取最底层窗口的参数,背景变灰色效果
WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
params.alpha = 0.5f;
getActivity().getWindow().setAttributes(params);
}
3.关闭窗口
/**
* 关闭窗口
*/
private void closePopupWindow() {
if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
popupWindow = null;
WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
params.alpha = 1f;
getActivity().getWindow().setAttributes(params);
}
}
4.adapter
/**
* popupWindow 设置适配器
*/
private class AdapterPopupWindow extends ArrayAdapter<IOCOutMakeMaterialSubmit.Data> {
private int resourceId; public AdapterPopupWindow(Context context, int resource, List<IOCOutMakeMaterialSubmit.Data> objects) {
super(context, resource, objects);
resourceId = resource;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
IOCOutMakeMaterialSubmit.Data data = getItem(position);
convertView = LayoutInflater.from(getContext()).inflate(resourceId,
null);
((TextView) convertView.findViewById(R.id.tv_pi_in_out_no)).setText(data.pi_inoutno);
((TextView) convertView.findViewById(R.id.tv_pi_class)).setText(data.pi_class);
((TextView) convertView.findViewById(R.id.tv_pd_wh_code)).setText(data.pd_whcode);
return convertView;
}
}
PopupWindow+ListView的更多相关文章
- 安卓PopupWindow+ListView实现登录账号选择下拉框
这段时间在做android开发,发现自定义下拉框有很多种方法实现,我介绍一种PopupWindow+ListView的方式,实现起来比较灵活.效果: 直接看核心代码: //获取文本框 etLoginN ...
- PopupWindow+ListView+OnItemClick点击无效
昨天踩了个大坑,从下午折腾到现在.实现以下功能: popupWindow显示listview,listView OnItemClick点击后获取值. 由于重写listview 是有两部分 列表正文和右 ...
- 下拉选择框加listview删除
package com.downselect; import java.util.ArrayList; import android.R.array; import android.app.Activ ...
- popupWindow使用详解
popupWindow说起来简单,但是使用略麻烦,今天带大家来看看怎么使用,先来看看效果图: 先来看看布局文件吧: <RelativeLayout xmlns:android="htt ...
- Android下拉选择框之PopupWindow
1.效果图 2.思路分析 1.点击弹出对话框 popupwindow 2.对popupwindow进行相关设置,popupwindow中设置view为listview 3.listview中item设 ...
- PopupWindow简单使用
如图是效果图 当点击 “点我”的按钮是 会弹出 如图的 弹窗 补充为PopupWindow设置一个显示动画和消失的动画 先在anim的文件下分别设置显示和消失的动画 <?xml versio ...
- 下拉选择框,PopupWindow的使用
实现下拉选择框 直接上代码 Activity.java package com.example.shaofei.customerviewdemo1; import android.os.Bundle; ...
- 窗口 对话框 Pop Dialog 示例
两者的区别 PopupWindow和AlertDialog最大的区别: AlertDialog是非阻塞线程的,AlertDialog弹出的时候,后台可以做其他事情(也即弹出对话框后程序会继续向下执行) ...
- 自定义一个仿Spinner
两个布局文件: adpter_list.xml <?xml version="1.0" encoding="utf-8"?> <LinearL ...
随机推荐
- ASP.NET母版页与内容页相对路径的问题
1. 图片问题 图片显示问题:<img runat="server" src="~/images/ad468x60.gif" alt="&quo ...
- Google Chrome 浏览器禁用缓存
在使用 Google Chrome 浏览器调试 js 时,会发现修改完 js 不会立即生效,这是由于 chrome 浏览器缓存的原因,而在火狐下没有这个问题.经常使用 chrome 浏览器调试 js ...
- Server Library [Apache Tomcat v6.0](unbound)服务未绑定解决办法
(1) 单击File按钮---钩选Show AllWizard——>选择Server——>单击Next (2)Add Library 选择 WTP Server Runtime(My ...
- JS之数组
1.数组的定义: (1)字面量: var arr = [1, 2, 3]; (2) new: var arr = new Array(1, 2, 3);(using new and don't ...
- C#程序大打开
打开一个已经存在的工程: 1.用vs打开(.sln)解决方案的文件.(若提示VS提示版本不一致,可用方法二) 2.删除(.sln)的文件.打开项目(.csproj) 文件或 (.vbproj) 文件, ...
- [PHP]利用XAMPP搭建本地服务器, 然后利用iOS客户端上传数据到本地服务器中(三. PHP端代码实现)
一.安装XAMPP http://www.cnblogs.com/lidongxu/p/5256330.html 二. 配置MySql http://www.cnblogs.com/lidongx ...
- Android百度地图开发05之公交信息检索 + 路线规划
在上一篇blog中介绍过POI检索的使用,本篇blog主要介绍公交信息检索和线路规划的内容. 公交信息检索 实际上,公交信息检索与POI检索.在线建议检索非常相似,也是把你需要检索的信息发送给百度地图 ...
- 查看Linux系统网卡信息
nmcli是一款能够方便我们配置网络的工具,能够轻松的查看网卡信息或网络状态: 实例1:查看网卡信息 [root@localhost ~]# nmcli connection show 名称 UUID ...
- Java SpringMVC实现国际化整合案例分析(i18n)
所谓国际化就是支持多种语言,web应用在不同的浏览环境中可以显示出不同的语言,比如说汉语.英语等.下面我将以具体的实例来举例说明: (1)新建动态Javaweb项目,并导入几个SpringMVC必需的 ...
- Mybatis Interceptor 拦截器原理 源码分析
Mybatis采用责任链模式,通过动态代理组织多个拦截器(插件),通过这些拦截器可以改变Mybatis的默认行为(诸如SQL重写之类的),由于插件会深入到Mybatis的核心,因此在编写自己的插件前最 ...