美文网首页
PopWindow展示月份

PopWindow展示月份

作者: 浮生若梦梦不归 | 来源:发表于2017-02-24 11:13 被阅读0次

首先设置月份列表

private void showPopupWindow(View view) {

final View contentView = LayoutInflater.from(NoticeActivity.this).inflate(R.layout.popwindow_principal_garten_choose, null);

if (popupWindowGartenChoose == null) {

popupWindowGartenChoose = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

popupWindowGartenChoose.setTouchable(true);

popupWindowGartenChoose.setTouchInterceptor(new View.OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

return false;

}

});

popupWindowGartenChoose.setBackgroundDrawable(new BitmapDrawable());

recycleview_garten = (RecyclerView) contentView.findViewById(R.id.recycleview_garten);

GridLayoutManager girdLayoutManager = new GridLayoutManager(this, 6);

recycleview_garten.setLayoutManager(girdLayoutManager);

noticeMonthAdapter = new NoticeMonthAdapter(classnameList);

noticeMonthAdapter.setOnItemClickListener(new onItemClickListener());

recycleview_garten.setAdapter(noticeMonthAdapter);

}

Rect viewRect = new Rect();

imgNotice.getGlobalVisibleRect(viewRect);

int height = CommomUtils.convertDpToPx(NoticeActivity.this, 45);

int distance = CommomUtils.getScreenH(NoticeActivity.this) / 2 - viewRect.bottom - height;

popupWindowGartenChoose.showAtLocation(view, Gravity.CENTER, 0, -distance);

}

在月份列表显示adapter中给点击事件添加tag

private intonclick=0;

@Override

public voidonClick(View v) {

intpos = (int) v.getTag();

if(onItemClickListener!=null) {

onItemClickListener.onItemClick(pos);

onclick= pos;

notifyDataSetChanged();

}

}

相关文章

网友评论

      本文标题:PopWindow展示月份

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