美文网首页
PopWindow基本弹出效果

PopWindow基本弹出效果

作者: Finder丶畅畅 | 来源:发表于2016-05-24 15:18 被阅读785次
if (popupWindow == null) {   
   LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);    
   view = layoutInflater.inflate(R.layout.pop_spinner, null);
   TotalListView listView = (TotalListView) view.findViewById(R.id.listview_pop);
   CommonAdapter<String> mAdapter = new CommonAdapter<String>(mInstance, getData(), R.layout.item_text) {
        @Override
        public void convert(ViewHolder holder, String s, int position) {
            holder.setText(R.id.item_text, s);
        }
    };    
listView.setAdapter(mAdapter);    
popupWindow = new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popupWindow.dismiss();
        }
   });
}
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);//在外部点击关闭
popupWindow.setBackgroundDrawable(new BitmapDrawable());//点击返回也可关闭,且不影响背景
popupWindow.setAnimationStyle(R.style.popwin_anim_style);//显示的位置
int y = (int) user_name_iet.getY();
popupWindow.showAsDropDown(user_name_iet, 0, -y - user_name_iet.getHeight());

相关文章

网友评论

      本文标题:PopWindow基本弹出效果

      本文链接:https://www.haomeiwen.com/subject/cdyzrttx.html