首先设置月份列表
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();
}
}
网友评论