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的更多相关文章

  1. 安卓PopupWindow+ListView实现登录账号选择下拉框

    这段时间在做android开发,发现自定义下拉框有很多种方法实现,我介绍一种PopupWindow+ListView的方式,实现起来比较灵活.效果: 直接看核心代码: //获取文本框 etLoginN ...

  2. PopupWindow+ListView+OnItemClick点击无效

    昨天踩了个大坑,从下午折腾到现在.实现以下功能: popupWindow显示listview,listView OnItemClick点击后获取值. 由于重写listview 是有两部分 列表正文和右 ...

  3. 下拉选择框加listview删除

    package com.downselect; import java.util.ArrayList; import android.R.array; import android.app.Activ ...

  4. popupWindow使用详解

    popupWindow说起来简单,但是使用略麻烦,今天带大家来看看怎么使用,先来看看效果图: 先来看看布局文件吧: <RelativeLayout xmlns:android="htt ...

  5. Android下拉选择框之PopupWindow

    1.效果图 2.思路分析 1.点击弹出对话框 popupwindow 2.对popupwindow进行相关设置,popupwindow中设置view为listview 3.listview中item设 ...

  6. PopupWindow简单使用

    如图是效果图 当点击 “点我”的按钮是   会弹出 如图的 弹窗 补充为PopupWindow设置一个显示动画和消失的动画 先在anim的文件下分别设置显示和消失的动画 <?xml versio ...

  7. 下拉选择框,PopupWindow的使用

    实现下拉选择框 直接上代码 Activity.java package com.example.shaofei.customerviewdemo1; import android.os.Bundle; ...

  8. 窗口 对话框 Pop Dialog 示例

    两者的区别 PopupWindow和AlertDialog最大的区别: AlertDialog是非阻塞线程的,AlertDialog弹出的时候,后台可以做其他事情(也即弹出对话框后程序会继续向下执行) ...

  9. 自定义一个仿Spinner

    两个布局文件: adpter_list.xml <?xml version="1.0" encoding="utf-8"?> <LinearL ...

随机推荐

  1. Keil RTX systick 初始化

    在STM32F215上移植Keil的RTX操作系统,随便设置下就能好使,但是当我想知道systick到底是怎么设置的时候,就得翻翻代码了,原来在 rt_HAL_CM.h中以一个内联函数的形式定义的 _ ...

  2. Google NACL 简介

    Back to README Getting Started This page tells you how to install Native Client and run demos, both ...

  3. HDU 2672 god is a girl (字符串处理,找规律,简单)

    题目 //1,1,2,3,5,8,13,21,34,55…… //斐波纳契数列 #include<math.h> #include<stdio.h> #include<s ...

  4. BZOJ 3224: Tyvj 1728 普通平衡树 vector

    3224: Tyvj 1728 普通平衡树 Description 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作:1. 插入x数2. 删除x数(若有多个相同的数,因只删除 ...

  5. js中几个正则表达式相关函数使用时g标志的作用

    首先,javascript中涉及到正则表达式的函数总共有6个,可分为两种: 1.第一种是作为字符串对象的方法,即以 String.fun(); 形式调用,这里包括 split.search.match ...

  6. I,P,B帧和PTS,DTS的关系

    http://www.cnblogs.com/qingquan/archive/2011/07/27/2118967.html 基本概念: I frame :帧内编码帧 又称intra picture ...

  7. Jenkins Master/Slave架构

    原文:http://www.cnblogs.com/itech/archive/2011/11/11/2245849.html 一 Jenkins Master/Slave架构 Master/Slav ...

  8. 317. Shortest Distance from All Buildings

    题目: Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where th ...

  9. 269. Alien Dictionary

    题目: There is a new alien language which uses the latin alphabet. However, the order among letters ar ...

  10. 关于LINUX权限-bash: ./startup.sh: Permission denied

    关于LINUX权限-bash: ./startup.sh: Permission denied <script type="text/javascript"></ ...