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


Java OnTouchListener類代碼示例

本文整理匯總了Java中android.view.View.OnTouchListener的典型用法代碼示例。如果您正苦於以下問題:Java OnTouchListener類的具體用法?Java OnTouchListener怎麽用?Java OnTouchListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnTouchListener類屬於android.view.View包,在下文中一共展示了OnTouchListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initEvent

import android.view.View.OnTouchListener; //導入依賴的package包/類
@Override
public void initEvent() {//必須調用
	super.initEvent();

	lvBottomMenu.setOnItemClickListener(this);
	
	vBaseBottomWindowRoot.setOnTouchListener(new OnTouchListener() {
		
		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			finish();
			return true;
		}
	});
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:BottomMenuWindow.java

示例2: setContentView

import android.view.View.OnTouchListener; //導入依賴的package包/類
/**設置該Activity界麵布局,並設置底部左右滑動手勢監聽
 * @param layoutResID
 * @param listener
 * @use 在子類中
 * *1.onCreate中super.onCreate後setContentView(layoutResID, this);
 * *2.重寫onDragBottom方法並實現滑動事件處理
 * *3.在導航欄左右按鈕的onClick事件中調用onDragBottom方法
 */
public void setContentView(int layoutResID, OnBottomDragListener listener) {
	setContentView(layoutResID);

	onBottomDragListener = listener;
	gestureDetector = new GestureDetector(this, this);//初始化手勢監聽類

	view = inflater.inflate(layoutResID, null);
	view.setOnTouchListener(new OnTouchListener() {
		
		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			return gestureDetector.onTouchEvent(event);
		}
	});
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:BaseActivity.java

示例3: setContentView

import android.view.View.OnTouchListener; //導入依賴的package包/類
/**設置該Activity界麵布局,並設置底部左右滑動手勢監聽
 * @param layoutResID
 * @param listener
 * @use 在子類中
 * *1.onCreate中super.onCreate後setContentView(layoutResID, this);
 * *2.重寫onDragBottom方法並實現滑動事件處理
 * *3.在導航欄左右按鈕的onClick事件中調用onDragBottom方法
 */
public void setContentView(int layoutResID, OnBottomDragListener listener) {
	setContentView(layoutResID);

	onBottomDragListener = listener;
	gestureDetector = new GestureDetector(this, this);//初始化手勢監聽類

	view = inflater.inflate(layoutResID, null);
	view.setOnTouchListener(new OnTouchListener() {

		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			return gestureDetector.onTouchEvent(event);
		}
	});
}
 
開發者ID:TommyLemon,項目名稱:APIJSON-Android-RxJava,代碼行數:25,代碼來源:BaseActivity.java

示例4: QMUIBasePopup

import android.view.View.OnTouchListener; //導入依賴的package包/類
/**
 * Constructor.
 *
 * @param context Context
 */
public QMUIBasePopup(Context context) {
    mContext = context;
    mWindow = new PopupWindow(context);
    mWindow.setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                mWindow.dismiss();
                return false;
            }
            return false;
        }
    });

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:23,代碼來源:QMUIBasePopup.java

示例5: init

import android.view.View.OnTouchListener; //導入依賴的package包/類
@Inject
void init() {
    this.notificationBarView = (OverlayNotificationBarView) ((LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.overlay_notification_bar, null);
    this.notificationTouchListener = new View(this.context);
    this.notificationTouchListener.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return OverlayNotificationController.this.notificationBarView.dispatchTouchEvent(event);
        }
    });
    this.notificationBarView.addListener((Object) this, new NotificationViewListener() {
        public void onNotificationViewClosed() {
            OverlayNotificationController.this.removeFromWindow();
            OverlayNotificationController.this.fireOnNotificationClosed();
        }
    });
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:17,代碼來源:OverlayNotificationController.java

示例6: init

import android.view.View.OnTouchListener; //導入依賴的package包/類
@Inject
void init() {
    this.notificationBarView = (ShadeNotificationBarView) ((LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.shade_notification_bar, null);
    this.notificationTouchListener = new View(this.context);
    this.notificationTouchListener.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == 1) {
                Rect viewRect = new Rect();
                v.getHitRect(viewRect);
                if (viewRect.contains(Math.round(v.getX() + event.getX()), Math.round(v.getY() + event.getY()))) {
                    ShadeNotificationController.this.fireOsnNotificationTouched();
                    ShadeNotificationController.this.notificationBarView.closePopup();
                }
            }
            return true;
        }
    });
    this.notificationBarView.addListener((Object) this, new ShadeNotificationBarView.NotificationViewListener() {
        public void onNotificationViewClosed() {
            ShadeNotificationController.this.removeFromWindow();
            ShadeNotificationController.this.fireOnNotificationClosed();
        }
    });
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:25,代碼來源:ShadeNotificationController.java

示例7: ClickFalse

import android.view.View.OnTouchListener; //導入依賴的package包/類
void ClickFalse(float progress) {
	if (progress == 0) {
		uploadProgress.setVisibility(View.VISIBLE);
		uploadProgress.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				return true;
			}
		});
	} else if (progress == 100) {
		uploadProgress.setVisibility(View.GONE);
		uploadProgress.setOnTouchListener(null);
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:17,代碼來源:SendPaoPaoPic.java

示例8: BasePopupWindowForListView

import android.view.View.OnTouchListener; //導入依賴的package包/類
public BasePopupWindowForListView(View contentView, int width, int height,
                                  boolean focusable, List<T> mDatas, Object... params) {
    super(contentView, width, height, focusable);
    this.mContentView = contentView;
    context = contentView.getContext();
    if (mDatas != null)
        this.mDatas = mDatas;

    if (params != null && params.length > 0) {
        beforeInitWeNeedSomeParams(params);
    }

    setBackgroundDrawable(new BitmapDrawable());
    setTouchable(true);
    setOutsideTouchable(true);
    setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                dismiss();
                return true;
            }
            return false;
        }
    });
    initViews();
    initEvents();
    init();
}
 
開發者ID:lpy19930103,項目名稱:MinimalismJotter,代碼行數:30,代碼來源:BasePopupWindowForListView.java

示例9: configureButtons

import android.view.View.OnTouchListener; //導入依賴的package包/類
private void configureButtons() {
    // Buttons control only interactive training session (they are hidden
    // during automatic training session).
    recordButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                interactiveTrainingController.record();
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                interactiveTrainingController.play();
            }
            return false;
        }
    });

    replayButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg) {
            if (replayButton.isEnabled()) {
                interactiveTrainingController.play();
            }
        }
    });
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:25,代碼來源:TrainingActivity.java

示例10: onMessageListInit

import android.view.View.OnTouchListener; //導入依賴的package包/類
protected void onMessageListInit(){
    messageList.init(toChatUsername, chatType, chatFragmentHelper != null ? 
            chatFragmentHelper.onSetCustomChatRowProvider() : null);
    setListItemClickListener();
    
    messageList.getListView().setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            inputMenu.hideExtendMenuContainer();
            return false;
        }
    });
    
    isMessageListInited = true;
}
 
開發者ID:turoDog,項目名稱:KTalk,代碼行數:18,代碼來源:EaseChatFragment.java

示例11: initView

import android.view.View.OnTouchListener; //導入依賴的package包/類
@Override
public void initView(View view) {
    initWebView();
    initBarAnim();
    mImgBack.setOnClickListener(this);
    mImgForward.setOnClickListener(this);
    mImgRefresh.setOnClickListener(this);
    mImgSystemBrowser.setOnClickListener(this);

    mGestureDetector = new GestureDetector(aty, new MyGestureListener());
    mWebView.loadUrl(mCurrentUrl);
    mWebView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return mGestureDetector.onTouchEvent(event);
        }
    });
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:19,代碼來源:BrowserFragment.java

示例12: show

import android.view.View.OnTouchListener; //導入依賴的package包/類
public LinearLayout show() {
    final LinearLayout mainLayout = new LinearLayout(this.ctx);
    final MenuItem that = this;
    this.articleView.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN) {
                mainLayout.setBackgroundColor(Color.parseColor("#EEEEEE"));
            }
            if(event.getAction() == MotionEvent.ACTION_UP) {
                mainLayout.setBackgroundColor(Color.WHITE);
                if(event.getX() > 0 && event.getY() > 0 && event.getX() < Utils.dip2px(that.ctx, 200) && event.getY() < Utils.dip2px(that.ctx, 25)) {
                    if(that.listener != null) that.listener.onClick(v);
                }
            }
            return true;
        }
    });
    mainLayout.setOrientation(0);
    mainLayout.setLayoutParams(new LinearLayout.LayoutParams(Utils.dip2px(this.ctx, 200), Utils.dip2px(this.ctx, 25)));
    mainLayout.addView(this.iconView);
    mainLayout.addView(this.articleView);
    return mainLayout;
}
 
開發者ID:AstinPE,項目名稱:FloatingApps,代碼行數:24,代碼來源:MenuItem.java

示例13: show

import android.view.View.OnTouchListener; //導入依賴的package包/類
public LinearLayout show() {
     final LinearLayout mainLayout = new LinearLayout(this.ctx);
     final MenuItem that = this;
     this.articleView.setOnTouchListener(new OnTouchListener() {
	public boolean onTouch(View v, MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_DOWN) {
			mainLayout.setBackgroundColor(Color.parseColor("#EEEEEE"));
		}
		if(event.getAction() == MotionEvent.ACTION_UP) {
			mainLayout.setBackgroundColor(Color.WHITE);
			if(event.getX() > 0 && event.getY() > 0 && event.getX() < Utils.dip2px(that.ctx, 200) && event.getY() < Utils.dip2px(that.ctx, 25)) {
				if(that.listener != null) that.listener.onClick(v);
			}
		}
		return true;
	}
});
     mainLayout.setOrientation(0);
     mainLayout.setLayoutParams(new LinearLayout.LayoutParams(Utils.dip2px(this.ctx, 200), Utils.dip2px(this.ctx, 25)));
     mainLayout.addView(this.iconView);
     mainLayout.addView(this.articleView);
     return mainLayout;
 }
 
開發者ID:AstinPE,項目名稱:StarchWindow,代碼行數:24,代碼來源:MenuItem.java

示例14: getDragToOpenListener

import android.view.View.OnTouchListener; //導入依賴的package包/類
public OnTouchListener getDragToOpenListener() {
    if (this.mDragListener == null) {
        this.mDragListener = new ForwardingListener(this.mAnchor) {
            protected boolean onForwardingStarted() {
                PopupMenu.this.show();
                return true;
            }

            protected boolean onForwardingStopped() {
                PopupMenu.this.dismiss();
                return true;
            }

            public ListPopupWindow getPopup() {
                return PopupMenu.this.mPopup.getPopup();
            }
        };
    }
    return this.mDragListener;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:PopupMenu.java

示例15: QsDetailItemsList

import android.view.View.OnTouchListener; //導入依賴的package包/類
private QsDetailItemsList(LinearLayout view) {
    mView = view;

    mListView = (ListView) mView.findViewById(android.R.id.list);
    mListView.setOnTouchListener(new OnTouchListener() {
        // Setting on Touch Listener for handling the touch inside ScrollView
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
    mEmpty = mView.findViewById(android.R.id.empty);
    mEmpty.setVisibility(View.GONE);
    mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
    mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
    mListView.setEmptyView(mEmpty);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:20,代碼來源:QsDetailItemsList.java


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