问题
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