道歉:- 由于我的错误,因为上次我没有正确地问这个问题,这就是为什么下面发布的大多数答案都与 “this”关键字有关,这就是我得到那么多反对票的原因。所以我更新了这个问题,因为我不想误导任何人。
.
编辑-1:
问题 1 我的问题是为什么我们在GestureDetectorCompact()构造函数中两次传递“this”(当前类或 MainActivity 的对象)
new GestureDetectorCompat(this,this);
其余代码块如下所示,
public class MainActivity extends ActionBarActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
protected void onCreate(){
private GestureDetectorCompat gestureDetector;
this.gestureDetector = new GestureDetectorCompat(this,this);
gestureDetector.setOnDoubleTapListener(this);
}
}
EDIT-2:对于非常接近的答案,您可以单击以下链接
EpicPandaForce 的回答非常接近我的问题,也很有帮助。