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;
}
}

最新文章

  1. 【BZOJ 4582】【Usaco2016 Open】Diamond Collector
  2. Map拷贝 关于对象深拷贝 浅拷贝的问题
  3. 关于Spring事务回滚的问题
  4. MFC 打开其他程序
  5. 正向代理与反向代理的区别【Nginx读书笔记】
  6. PHP与Java进行通信
  7. [IOS UIScrollView+PageControl]信息展示横幅
  8. 【IDE】SharpDevelop
  9. bzoj 3289 Mato的文件管理(莫队算法+BIT)
  10. Java和MongoDB之Hello World
  11. .Net remoting, Webservice,WCF,Socket区别
  12. POJ 3261 可重叠的 k 次最长重复子串【后缀数组】
  13. ssis 到别的表查找临时变量值
  14. JPA 系列教程17-继承-独立表-TABLE_PER_CLASS
  15. 关于IntelliJ IDEA有时候快捷键无效的说明
  16. Django-1- urls的路由配置, 命名, 重定向, path及re_path
  17. cpp 区块链模拟示例(二)工程代码解析
  18. RabbitMQ的Vhost,Exchange,Queue原理分析
  19. cookie 和 session 的一些事 中间件
  20. js Map和Set

热门文章

  1. tar命令--解压缩
  2. 如何用 Parse 和 Swift 搭建一个像 Instagram 那样的应用?
  3. javascript中的JSON序列化与反序列化
  4. 10个免费开源的JS音乐播放器插件
  5. 关于在linux下清屏的几种技巧
  6. Android核心分析之二十三Andoird GDI之基本原理及其总体框架
  7. iOS开发--轮播图
  8. 301. Remove Invalid Parentheses
  9. ADB调试桥安装(方式二)
  10. Oracle -&gt;&gt; 变量赋值 Demo