@Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    // BUG #57535
    // 【发帖】发帖页面键盘弹出后,如果这时点击手机的HOME键、电源键或其他输入键盘上手机自带按钮进入其他页面,再返回到发帖页面,输入键盘会隐藏,小键盘按钮会高亮显示
    if (isOpenComment) {
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int[] l = {0, 0};
        mEditContent.getLocationInWindow(l);
        int left = l[0], top = l[1];
        int bottom = top + mEditContent.getHeight(), right = left + mEditContent.getWidth();
        System.out.println(
            "left:" + left + "; top:" + top + ";bottom:" + bottom + ";right:" + right);
        if (event.getX() > left
            && event.getX() < right
            && event.getY() > top
            && event.getY() < bottom) {
          mInputBar.showCommonInputBar();
          // return false;
        } else {
          InputMethodUtils.collapseSoftInputMethod(mContext, mEditContent.getWindowToken());
          // return true;
        }
      }
    }

    return super.dispatchTouchEvent(event);
  }
예제 #2
0
 @Override
 public boolean onTouch(View arg0, MotionEvent event) {
   if (editText.getCompoundDrawables()[2] != null) {
     if (event.getAction() == MotionEvent.ACTION_UP) {
       boolean touchable =
           event.getX()
                   > (editText.getWidth()
                       - editText.getPaddingRight()
                       - mClearDrawable.getIntrinsicWidth())
               && (event.getX() < ((editText.getWidth() - editText.getPaddingRight())));
       if (touchable) {
         editText.setText("");
       }
     }
   }
   return super.onTouchEvent(event);
 }
  private void showPopWindow() {
    if (popupWindow == null) {
      popupWindow = new PopupWindow(listView, et_content.getWidth(), popWindowHeigth);
    }

    popupWindow.setFocusable(true);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    // popupWindow.setOutsideTouchable(true);
    // popupWindow.setTouchable(true);
    popupWindow.showAsDropDown(et_content, 0, 0);
  }
예제 #4
0
 private void showPopupWindow() {
   // 隐藏和显示切换
   if (mPw != null && mPw.isShowing()) {
     mPw.dismiss();
   } else {
     // 获取et的宽度
     et_number.measure(0, 0);
     mPw.setWidth(et_number.getWidth());
     mPw.showAsDropDown(et_number);
   }
 }
예제 #5
0
  public void showPopupWindow() {
    if (popupWindow == null) {
      popupWindow = new PopupWindow(listView, et_colors.getWidth(), 400);
      popupWindow.setFocusable(true);
      popupWindow.setBackgroundDrawable(new BitmapDrawable());
      popupWindow.setOutsideTouchable(true);
    }
    if (!isShowPopupWindow) {
      popupWindow.showAsDropDown(et_colors, 0, 0);
    } else {
      popupWindow.dismiss();
    }

    isShowPopupWindow = !isShowPopupWindow;
  }
예제 #6
0
  /** 初始化PopupWindow */
  private void initPopuWindow() {

    // initDatas();

    // PopupWindow浮动下拉框布局
    View resultView = (View) this.getLayoutInflater().inflate(R.layout.point_result_options, null);
    ListView listView = (ListView) resultView.findViewById(R.id.list);

    // 设置自定义Adapter
    resultAdapter = new PointResultAdapter(this, mHandler);
    listView.setAdapter(resultAdapter);
    // 获取下拉框依附的组件宽度
    resulePopupWindow =
        new PopupWindow(resultView, startText.getWidth(), LayoutParams.WRAP_CONTENT, false);
    resulePopupWindow.setOutsideTouchable(true);
  }
예제 #7
0
 /**
  * 隐藏软键盘 时判断输入框的位置
  *
  * @param v
  * @param event
  * @return
  */
 public static boolean isShouldHideInput(View v, MotionEvent event, EditText ed) {
   if (v != null && (v instanceof EditText)) {
     int[] leftTop = {0, 0};
     // 获取输入框当前的location位置
     ed.getLocationInWindow(leftTop);
     int left = leftTop[0];
     int top = leftTop[1];
     int bottom = top + ed.getHeight();
     int right = left + ed.getWidth();
     if (event.getX() > left
         && event.getX() < right
         && event.getY() > top
         && event.getY() < bottom) {
       // 点击的是输入框区域,保留点击EditText的事件
       return false;
     } else {
       return true;
     }
   }
   return false;
 }