当前位置: 首页>>代码示例>>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;未经允许,请勿转载。