class DropListPopWin(var context: Context) : PopupWindow() {
var layoutInflater: LayoutInflater
lateinit var target: View
var mData: List<String>? = null
init {
layoutInflater = LayoutInflater.from(context)
isFocusable = true
isTouchable = true
isOutsideTouchable = true
}
constructor(context: Context, view: View,mData:List<String>) : this(context) {
target=view
this.mData=mData
initView(context)
}
fun initView(context: Context) {
this.target = target
width = target.measuredWidth
height = ViewGroup.LayoutParams.WRAP_CONTENT
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
contentView = layoutInflater.inflate(R.layout.home_pop_list, null)
var listView = contentView.findViewById<RecyclerView>(R.id.list)
listView.layoutManager=LinearLayoutManager(context)
listView.adapter = ListViewAdapter(mData!!, context)
super.setContentView(contentView)
}
fun show() {
var targetHeight = target.height
showAsDropDown(target!!, 0, -targetHeight / 2)
}
}