當前位置: 首頁>>代碼示例>>Java>>正文


Java GestureDetector.onTouchEvent方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:11,代碼來源:QuranImagePageLayout.java

示例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);

}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:13,代碼來源:RecipeMainActivity.java

示例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();
            }
        }

    }
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:62,代碼來源:ReadingFragment.java


注:本文中的android.view.GestureDetector.onTouchEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。