版权声明:本文为延成原创文章,转载请标明出处
/**
* 自定义PopupWindow
*/
public class AutoAttentionPopupWindow extends PopupWindow {
private static final String TAG = AutoAttentionPopupWindow.class.getSimpleName();
private View mMenuView;
private Context mContext;
private View.OnClickListener mOnClick;
private SimpleDraweeView mSdv_head_icon;
public AutoAttentionPopupWindow(Context context, View.OnClickListener onClick) {
super(context);
this.mContext = context;
this.mOnClick = onClick;
init();
}
private void init() {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mMenuView = inflater.inflate(R.layout.window_auto_attention, null);
mSdv_head_icon = (SimpleDraweeView) mMenuView.findViewById(R.id.sdv_head_icon);
ImageView iv_close = (ImageView) mMenuView.findViewById(R.id.iv_close);
TextView tv_attention = (TextView) mMenuView.findViewById(R.id.tv_attention);
tv_attention.setOnClickListener(mOnClick);
iv_close.setOnClickListener(mOnClick);
this.setContentView(mMenuView);
this.setBackgroundDrawable(mContext.getResources().getDrawable(R.color.transparent));
this.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
}
public void show(View view,String icon) {
FrescoUtils.showUrl(mSdv_head_icon, icon);
this.showAtLocation(view, Gravity.BOTTOM, 0, 0);
}
}