本文整理汇总了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;
}
});
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
示例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();
}
});
}
示例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();
}
});
}
示例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);
}
}
示例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();
}
示例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();
}
}
});
}
示例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;
}
示例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);
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}