GestureDetector Deprecated Issue

血红的双手。 提交于 2019-12-10 12:28:23

问题


I have this code

itemizedOverlay = new MyItemizedOverlay(drawable,this);
itemizedOverlay.setGestureDetector(new GestureDetector(new MyGestureDetecor()));

but new GestureDetector is marked as Deprecated in Eclipse.

I want to avoid the use of deprecated methods.

How could I fix this problem?

What is the non-deprecated form?


回答1:


Choose one of the other constructors. There are five defined constructors on GestureDetector. Two -- the ones not including a Context as the first parameter -- are marked as deprecated. You are using one of those.




回答2:


There are just two deprecated constructors. If you add the context to GestureDetector(context, listener) it's not deprecated.




回答3:


1 try add Context to your method: `

itemizedOverlay = new MyItemizedOverlay(drawable,this); itemizedOverlay.setGestureDetector(Context context new GestureDetector(new MyGestureDetecor()));`

2 if you already have call to class Context in your method try:

itemizedOverlay = new MyItemizedOverlay(drawable,this); itemizedOverlay.setGestureDetector(new GestureDetector(context new MyGestureDetecor()));



来源:https://stackoverflow.com/questions/12873708/gesturedetector-deprecated-issue

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