setOnClickListener of a ListView not working

前端 未结 5 1550
挽巷
挽巷 2020-12-09 04:06

So I\'m trying to set up a setOnClickListener for my ListView but it\'s causing a crash in my program for some reason when I try... I\'m quite new

5条回答
  •  旧巷少年郎
    2020-12-09 04:51

    In my case I try to add onClickListener for spinner and I've got the same problem. I've crated workaround with touch listener. Sometimes we need it for hideKeyBoard or send some analyticEvent:

    someSpinner.setOnTouchListener { _, event ->  onTouchSomeSpinner(event)}
    
    fun onTouchSomeSpinner(event: MotionEvent): Boolean {
            if(event.action == MotionEvent.ACTION_UP) {
                view.hideKeyBoard()
                view.analyticsEvent()
                ...
            }
            return false
    }
    

提交回复
热议问题