public void popWindow(View parent){
if (popupWindow==null) {
View view = LayoutInflater.from(this).inflate(R.layout.acccompany_treatment_manager_layout,null);
LinearLayout linearLayout1= (LinearLayout) view.findViewById(R.id.linear1);
linearLayout1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow!=null){
popupWindow.dismiss();
Drawable drawable= getResources().getDrawable(R.mipmap.i_arrow_down);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvServiceName.setCompoundDrawables(null,null,drawable,null);
}
}
});
listView = (ListView) view.findViewById(R.id.lvList);
listView.setAdapter(adapter);
listView.setItemsCanFocus(false);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
tvServiceName.setText(hospitalAccompanyServices.get(position).getServiceName()+":"+hospitalAccompanyServices.get(position).getUnitPrice()+"元");
popupWindow.dismiss();
Drawable drawable= getResources().getDrawable(R.mipmap.i_arrow_down);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvServiceName.setCompoundDrawables(null,null,drawable,null);
}
});
popupWindow=new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setFocusable(true );
popupWindow.setTouchable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.update();
popupWindow.showAsDropDown(parent);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Drawable drawable= getResources().getDrawable(R.mipmap.i_arrow_down);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvServiceName.setCompoundDrawables(null,null,drawable,null);
}
});
}
PopupWindow的使用
最新推荐文章于 2017-09-08 10:49:07 发布