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

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

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

Dialog.getCurrentFocus介绍

暂无

代码示例

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

  1. public static void hideSoftInput(Dialog dialog) {
  2. View view = dialog.getCurrentFocus();
  3. if (view != null) {
  4. InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  5. imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  6. }
  7. }
  8. }

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

  1. private DiaryTextTag checkoutOldDiaryContent() {
  2. View focusView = getDialog().getCurrentFocus();
  3. DiaryTextTag tag = null;
  4. if (focusView instanceof EditText && focusView.getTag() != null &&
  5. focusView.getTag() instanceof DiaryTextTag) {
  6. EditText currentEditText = (EditText) focusView;
  7. tag = (DiaryTextTag) focusView.getTag();
  8. if (currentEditText.getText().toString().length() > 0) {
  9. int index = currentEditText.getSelectionStart();
  10. String nextEditTextStr = currentEditText.getText().toString()
  11. .substring(index, currentEditText.getText().toString().length());
  12. currentEditText.getText().delete(index, currentEditText.getText().toString().length());
  13. tag.setNextEditTextStr(nextEditTextStr);
  14. }
  15. }
  16. return tag;
  17. }

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

  1. private void hideKeyboard() {
  2. try {
  3. InputMethodManager imm = (InputMethodManager) editSendMessage.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  4. if (imm!=null&&getDialog()!=null) {
  5. imm.hideSoftInputFromWindow(getDialog().getCurrentFocus().getWindowToken(),
  6. InputMethodManager.HIDE_NOT_ALWAYS);
  7. }
  8. }catch (Exception e){
  9. }
  10. }

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

  1. @Override
  2. public void hideKeyboard() {
  3. View view = this.getDialog().getCurrentFocus();
  4. if (view != null) {
  5. InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  6. imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  7. }
  8. if (mActivity != null) {
  9. mActivity.hideKeyboard();
  10. }
  11. }
  12. }

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

  1. public static void autoHideSoftInput(Dialog dialog, MotionEvent event) {
  2. View focusView = dialog.getCurrentFocus();
  3. if (null == focusView) {
  4. return;
  5. }
  6. if (isAutoHideSoftInput(focusView, event)) {
  7. FRInputMethodManager.hideSoftInput(dialog, focusView);
  8. }
  9. }

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

  1. @Override
  2. public void onTextChanged(CharSequence s, int start, int before, int count) {
  3. EditText editText = (EditText) getDialog().getCurrentFocus();
  4. if (editText.length() == 2) {
  5. View view = editText.focusSearch(View.FOCUS_RIGHT);
  6. if (view != null) {
  7. view.requestFocus();
  8. }
  9. }
  10. }

相关文章