android.app.Dialog.getCurrentFocus()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(327)

本文整理了Java中android.app.Dialog.getCurrentFocus()方法的一些代码示例,展示了Dialog.getCurrentFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dialog.getCurrentFocus()方法的具体详情如下:
包路径:android.app.Dialog
类名称:Dialog
方法名:getCurrentFocus

Dialog.getCurrentFocus介绍

暂无

代码示例

代码示例来源:origin: seven332/EhViewer

public static void hideSoftInput(Dialog dialog) {
    View view = dialog.getCurrentFocus();
    if (view != null) {
      InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
  }
}

代码示例来源:origin: DaxiaK/MyDiary

private DiaryTextTag checkoutOldDiaryContent() {
  View focusView = getDialog().getCurrentFocus();
  DiaryTextTag tag = null;
  if (focusView instanceof EditText && focusView.getTag() != null &&
      focusView.getTag() instanceof DiaryTextTag) {
    EditText currentEditText = (EditText) focusView;
    tag = (DiaryTextTag) focusView.getTag();
    if (currentEditText.getText().toString().length() > 0) {
      int index = currentEditText.getSelectionStart();
      String nextEditTextStr = currentEditText.getText().toString()
          .substring(index, currentEditText.getText().toString().length());
      currentEditText.getText().delete(index, currentEditText.getText().toString().length());
      tag.setNextEditTextStr(nextEditTextStr);
    }
  }
  return tag;
}

代码示例来源:origin: anyRTC/anyRTC-RTMPC-Android

private void hideKeyboard() {
  try {
    InputMethodManager imm = (InputMethodManager) editSendMessage.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm!=null&&getDialog()!=null) {
      imm.hideSoftInputFromWindow(getDialog().getCurrentFocus().getWindowToken(),
          InputMethodManager.HIDE_NOT_ALWAYS);
    }
  }catch (Exception e){
  }
}

代码示例来源:origin: playerone-id/EosCommander

@Override
  public void hideKeyboard() {
    View view = this.getDialog().getCurrentFocus();
    if (view != null) {
      InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    if (mActivity != null) {
      mActivity.hideKeyboard();
    }
  }
}

代码示例来源:origin: AndroidFriendsGroup/FRDialog

public static void autoHideSoftInput(Dialog dialog, MotionEvent event) {
  View focusView = dialog.getCurrentFocus();
  if (null == focusView) {
    return;
  }
  if (isAutoHideSoftInput(focusView, event)) {
    FRInputMethodManager.hideSoftInput(dialog, focusView);
  }
}

代码示例来源:origin: vanilla-music/vanilla

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  EditText editText = (EditText) getDialog().getCurrentFocus();
  if (editText.length() == 2) {
    View view = editText.focusSearch(View.FOCUS_RIGHT);
    if (view != null) {
      view.requestFocus();
    }
  }
}

相关文章