Android 更新PopupWindow里ContentView中具体的控件【显示,隐藏】
程序员文章站
2024-03-23 21:45:04
...
goodLIbHisKindImg.setImageResource(R.drawable.ic_gray_down)
mContView = View.inflate(this, R.layout.activity_pop_goodoutlib_layout, null)
popWindow = PopupWindow(mContView,LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true)
// 在PopupWindow里面就加上下面代码,让键盘弹出时,不会挡住pop窗口。
popWindow.inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
popWindow.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING
popWindow.isOutsideTouchable = true
popWindow.contentView.measure(ViewUtils.makeDropDownMeasureSpec(popWindow.width), ViewUtils.makeDropDownMeasureSpec(popWindow.height))
popWindow.showAsDropDown(goodLibHisRel,0,0, Gravity.START)
val hisAll = popWindow.contentView.findViewById<LinearLayout>(R.id.goodsOutHisAllLin)
hisAllImg = popWindow.contentView.findViewById(R.id.goodsOutHisAllImg)
hisAllTv = popWindow.contentView.findViewById<TextView>(R.id.goodsOutHisAllTv)
hisAll.setOnClickListener {
handler.sendEmptyMessage(SHOWHISAllIMG)
}
private val handler = object: Handler(Looper.getMainLooper()){
override fun handleMessage(msg: Message?) {
super.handleMessage(msg)
when(msg?.what) {
SHOWHISAllIMG ->{
setSelect(hisAllImg,hisAllTv)
setNotSelect(hisHandImg, hisHandTv)
setNotSelect(hisOrderImg, hisOrderTv)
mContView.invalidate()
popWindow.update()
this.sendEmptyMessageDelayed(DISMISSPOPWINDOW,DISMISSPOPWINDOWTIME)
}
}
上一篇: [算法竞赛进阶指南]Hamilton路径(状压dp)
下一篇: java中一些常用的关键字的小总结