本文整理汇总了Java中android.view.GestureDetector.onTouchEvent方法的典型用法代码示例。如果您正苦于以下问题:Java GestureDetector.onTouchEvent方法的具体用法?Java GestureDetector.onTouchEvent怎么用?Java GestureDetector.onTouchEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.GestureDetector
的用法示例。
在下文中一共展示了GestureDetector.onTouchEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPageController
import android.view.GestureDetector; //导入方法依赖的package包/类
@Override
public void setPageController(PageController controller, int pageNumber) {
super.setPageController(controller, pageNumber);
final GestureDetector gestureDetector = new GestureDetector(context,
new PageGestureDetector());
OnTouchListener gestureListener = (v, event) -> gestureDetector.onTouchEvent(event);
imageView.setOnTouchListener(gestureListener);
imageView.setClickable(true);
imageView.setLongClickable(true);
}
示例2: setupGestureDetection
import android.view.GestureDetector; //导入方法依赖的package包/类
private void setupGestureDetection() {
final GestureDetector gestureDetector = new GestureDetector(this, new SwipeGestureDetector(this));
View.OnTouchListener gestureOnTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return gestureDetector.onTouchEvent(motionEvent);
}
};
imgRecipe.setOnTouchListener(gestureOnTouchListener);
}
示例3: onActivityCreated
import android.view.GestureDetector; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
displayPageNumber(-1); // Initializes the pagenumber view properly
final GestureDetector gestureDetector = new GestureDetector(context,
new NavGestureDetector(bookView, this, metrics));
View.OnTouchListener gestureListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
};
this.viewSwitcher.setOnTouchListener(gestureListener);
this.bookView.setOnTouchListener(gestureListener);
this.dummyView.setOnTouchListener(gestureListener);
registerForContextMenu(bookView);
saveConfigState();
Intent intent = getActivity().getIntent();
String file = null;
if ( intent.getData() != null) {
file = intent.getData().getPath();
}
if (file == null) {
file = "";
file = config.getLastOpenedFile();
}
updateFromPrefs();
updateFileName(savedInstanceState, file);
if ("".equals(fileName) || ! new File(fileName).exists() ) {
LOG.info( "Requested to open file " + fileName + ", which doesn't seem to exist. " +
"Switching back to the library.");
Toast.makeText(getContext(), "File not exits!", Toast.LENGTH_SHORT).show();
return;
} else {
if (savedInstanceState == null && config.isSyncEnabled()) {
// new DownloadProgressTask().execute();
} else {
bookView.restore();
}
}
}