我在另一台RecyclerView中有RecyclerView。当点击内部RecyclerView的项目时,我将如下所示显示PopupWindow。
当用户点击弹出窗口内的按钮时,外部RecyclerView的项目应该更新数据。问题是,在更新外部项notifyItemChanged(position)
之后,PopupWindow显示在片段的左上角,而不是在内部RecyclerView的下面。
override fun onBindViewHolder(holder : MessageItemHolder, messagePosition : Int)
{
val item = messages[messagePosition]
//Display some data
if(item.isRateViewOpened)
showRatePopup(holder, messagePosition, item)
holder.tvMessage.setOnLongClickListener {
showRatePopup(holder, messagePosition, item)
true
}
}
private fun showRatePopup(holder : MessageItemHolder, messagePosition : Int, message : Message)
{
messages[messagePosition].isRateViewOpened = true
val rateView = layoutInflater.inflate(R.layout.popup_rate, null)
setRateIcons(message.status, rateView)
rateView.ibLike.setOnClickListener { displayRateStatus(RateStatus.LIKE, message, messagePosition, rateView) }
rateView.ibDislike.setOnClickListener { displayRateStatus(RateStatus.DISLIKE, message, messagePosition, rateView) }
val popupWindow = PopupWindow(rateView, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, true)
popupWindow.setBackgroundDrawable(ColorDrawable())
popupWindow.isOutsideTouchable = true
val location = IntArray(2)
holder.tvMessage.getLocationOnScreen(location)
popupWindow.showAsDropDown(holder.tvMessage, 0, 0, Gravity.NO_GRAVITY)
popupWindow.setOnDismissListener {
messages[messagePosition].isRateViewOpened = false
}
}