@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; } }); }
/**设置该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); } }); }
/** * 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); }
@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(); } }); }
@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(); } }); }
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); } }
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(); }
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(); } } }); }
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; }
@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); } }); }
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; }
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; }
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); }
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; } }); messageList.setIRcBack(this); isMessageListInited = true; }
/** * @param builder SlideDrawerHelper建造者 */ private SlideDrawerHelper(@NonNull Builder builder) { ViewGroup dragLayout = builder.dragLayout;// 滑动触发布局,可拖动或点击 this.slideParentLayout = builder.slideParentLayout; this.minHeight = builder.minHeight; this.mediumHeight = builder.mediumHeight; this.maxHeight = builder.maxHeight; this.animDuration = builder.animDuration; this.removeMediumHeightState = builder.removeMediumHeightState; this.clickSlidable = builder.clickSlidable; this.mediumClickSlideState = builder.mediumClickSlideState; dragLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { handleSlide(event); return true; } }); }
/** * Create a QuickAction * * @param anchor * the view that the QuickAction will be displaying 'from' */ public CustomPopupWindow(View anchor) { this.anchor = anchor; this.window = new PopupWindow(anchor.getContext()); // when a touch even happens outside of the window // make the window go away window.setTouchInterceptor(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // FIXME : the setOutsideTouchable flag is set but it seems we never get ACTION_OUTSIDE events if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { CustomPopupWindow.this.window.dismiss(); return true; } return false; } }); windowManager = (WindowManager) anchor.getContext().getSystemService(Context.WINDOW_SERVICE); onCreate(); }
@SuppressWarnings("deprecation") public SelectRemindCyclePopup(Context context) { mContext = context; mPopupWindow = new PopupWindow(context); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setWidth(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setHeight(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setAnimationStyle(R.style.AnimBottom); mPopupWindow.setContentView(initViews()); mPopupWindow.getContentView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mPopupWindow.setFocusable(false); // mPopupWindow.dismiss(); return true; } }); }
@SuppressWarnings("deprecation") public SelectRemindWayPopup(Context context) { mContext = context; mPopupWindow = new PopupWindow(context); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setWidth(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setHeight(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setAnimationStyle(R.style.AnimBottom); mPopupWindow.setContentView(initViews()); mPopupWindow.getContentView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mPopupWindow.setFocusable(false); mPopupWindow.dismiss(); return true; } }); }
public PopupWindows(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 true; } return false; } }); mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); }
/** * Constructor. * * @param context Context */ public PopupWindows(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 true; } return false; } }); mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); }
protected void onMessageListInit(){ messageList.init(toChatUsername, chatType, chatFragmentListener != null ? chatFragmentListener.onSetCustomChatRowProvider() : null); //设置list item里的控件的点击事件 setListItemClickListener(); messageList.getListView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); inputMenu.hideExtendMenuContainer(); return false; } }); isMessageListInited = true; }
public CustomPopupWindow(View anchor) { this.anchor = anchor; this.window = new PopupWindow(anchor.getContext()); // Если происходит прикосновение за пределами диалогового окна,то окно закрывается window.setTouchInterceptor(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { CustomPopupWindow.this.window.dismiss(); return true; } return false; } }); windowManager = (WindowManager) anchor.getContext().getSystemService(Context.WINDOW_SERVICE); onCreate(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); me = this; this.setContentView(R.layout.dialog_message); rl_view = (RelativeLayout) findViewById(R.id.rl_message_dialog); lv_option = (ListView) findViewById(R.id.lv_message_deal); rl_view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { me.cancel(); return false; } }); /*WindowManager.LayoutParams lp=getWindow().getAttributes(); lp.alpha = 0.9f;//透明度设置 getWindow().setAttributes(lp);*/ optionShow(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); me = this; this.setContentView(R.layout.dialog_av); rl_view = (RelativeLayout) findViewById(R.id.rl_av_dialog); lv_option = (ListView) findViewById(R.id.lv_av_option); rl_view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { me.cancel(); return false; } }); stateList = new ArrayList<NameState>(); /*WindowManager.LayoutParams lp=getWindow().getAttributes(); lp.alpha = 0.9f;//透明度设置 getWindow().setAttributes(lp);*/ optionShow(); }
public PopupWindows(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 true; } return false; } }); mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); }
private void initListView() { list_friends = (ListView) findViewById(R.id.list_friends); userAdapter = new UserFriendAdapter(getActivity(), friends); list_friends.setAdapter(userAdapter); list_friends.setOnItemClickListener(this); list_friends.setOnItemLongClickListener(this); list_friends.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { // 隐藏软键盘 if (getActivity().getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow( getActivity().getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }