android-使用Popupwindow
程序员文章站
2022-06-25 15:08:04
PopWindwos弹窗private fun showStockPickPopupWindow(context: Context?, currentView: View, data: FStockPickerIndexEntity) { if (mLongPressSelectPopupWindow != null && mLongPressSelectPopupWindow!!.isShowing) { return }....
PopWindwos弹窗
private fun showStockPickPopupWindow(context: Context?, currentView: View, data: FStockPickerIndexEntity) {
if (mLongPressSelectPopupWindow != null && mLongPressSelectPopupWindow!!.isShowing) {
return
}
val rootView = LayoutInflater.from(context).inflate(R.layout.popupwindow_stock_pick, null)
val tv_change_index = rootView.findViewById<TextView>(R.id.tv_change_index)
val tv_change_name = rootView.findViewById<View>(R.id.tv_change_name)
val tv_delete = rootView.findViewById<TextView>(R.id.tv_delete)
tv_change_index.setOnClickListener {
ToastHelper.toastLong("修改指标")
FLaunchHelper.launchToStockPicker(mActivity)
mLongPressSelectPopupWindow!!.dismiss()
}
tv_change_name.setOnClickListener {
ToastHelper.toastLong("重命名")
mLongPressSelectPopupWindow!!.dismiss()
showChangeNameDialog(data)
}
tv_delete.setOnClickListener {
ToastHelper.toastLong("删除")
deleteStock(data)
mLongPressSelectPopupWindow!!.dismiss()
}
mLongPressSelectPopupWindow = PopupWindow(rootView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
mLongPressSelectPopupWindow!!.isOutsideTouchable = true
mLongPressSelectPopupWindow!!.isFocusable = true
mLongPressSelectPopupWindow!!.setBackgroundDrawable(ColorDrawable())
mLongPressSelectPopupWindow!!.isClippingEnabled = false
mLongPressSelectPopupWindow!!.setOnDismissListener { }
mLongPressSelectPopupWindow!!.showAsDropDown(currentView, AutoSizeUtils.pt2px(context, 518f), -(currentView.height - AutoSizeUtils.pt2px(context, 72f)))
val lp = this.window.attributes
lp.alpha = 0.3f
this.window.attributes = lp
mLongPressSelectPopupWindow?.setOnDismissListener(object : PopupWindow.OnDismissListener {
override fun onDismiss() {
lp.alpha = 1.0f
window.attributes = lp
}
})
}
本文地址:https://blog.csdn.net/mlsnatalie/article/details/108128500
上一篇: 圣诞节礼物篇,给你一个大大的惊喜
下一篇: 描写丽江的美文摘抄