ViewPager and longclick

心不动则不痛 提交于 2019-12-22 12:41:24

问题


I have a layout that is over top of a viewpager.

The viewpager is functioning as a dynamically changing background.

Upon a long click of the viewpager (long clicking the background), the foreground elements should disappear.

I put a long click listener on the viewpager, but it doesn't respond to this out of the box. This linked answer seems to touch on the subject, but I'm not sure how to implement it, help?

https://stackoverflow.com/a/11303508/727429

I'm also experimenting with other UX (clicks vs buttons vs motion gestures to do the same thing) but for now I want to solve this problem


回答1:


The answer is to set a listener inside the viewpager's instantiateItem class.

Basically declare your View within that, and set an onClickListener on that



来源:https://stackoverflow.com/questions/14554450/viewpager-and-longclick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!