当前位置: 首页>>代码示例>>Java>>正文


Java EditText.hasFocus方法代码示例

本文整理汇总了Java中android.widget.EditText.hasFocus方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.hasFocus方法的具体用法?Java EditText.hasFocus怎么用?Java EditText.hasFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.hasFocus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectionRange

import android.widget.EditText; //导入方法依赖的package包/类
@JSMethod
public void getSelectionRange(String callbackId) {
  EditText hostView;
  Map<String, Object> result = new HashMap<>(2);
  if ((hostView = getHostView()) != null) {
    int start = hostView.getSelectionStart();
    int end = hostView.getSelectionEnd();

    if (!hostView.hasFocus()) {
      //The default behavior, same as iOS and web
      start = 0;
      end = 0;
    }

    result.put(Constants.Name.SELECTION_START, start);
    result.put(Constants.Name.SELECTION_END, end);
  }
  WXBridgeManager.getInstance().callback(getInstanceId(), callbackId, result, false);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:20,代码来源:AbstractEditComponent.java

示例2: showKeyboard

import android.widget.EditText; //导入方法依赖的package包/类
public static void showKeyboard(final Activity activity, final EditText editText, final int i, String text, String hint) {
    editText.requestFocus();
    editText.hasFocus();
    editText.setText(text);
    editText.setHint(hint);
    editText.setSelection(editText.length());
    new Handler().postDelayed(new Runnable() {
        public void run() {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
            sharedPref.edit().putInt("keyboard", i).apply();
            activity.invalidateOptionsMenu();
            InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
        }
    }, 200);
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:17,代码来源:helper_editText.java

示例3: openIME

import android.widget.EditText; //导入方法依赖的package包/类
public void openIME(final EditText v) {
    final boolean focus = v.requestFocus();
    if (v.hasFocus()) {
        final Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                InputMethodManager mgr = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                boolean result = mgr.showSoftInput(v, InputMethodManager.SHOW_FORCED);
                log.debug("openIME " + focus + " " + result);
            }
        });
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:15,代码来源:BaseActivity.java

示例4: EditTextSelectionState

import android.widget.EditText; //导入方法依赖的package包/类
public EditTextSelectionState(@NonNull EditText editText) {
    mEditText = editText;
    mFocused = editText.hasFocus();
    int selectionStart = editText.getSelectionStart();
    int selectionEnd = editText.getSelectionEnd();
    if (selectionStart > selectionEnd && selectionStart != -1 && selectionEnd != -1) {
        mSelectionStart = selectionEnd;
        mSelectionEnd = selectionStart;
    } else {
        mSelectionStart = selectionStart;
        mSelectionEnd = selectionEnd;
    }
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:14,代码来源:EditTextSelectionState.java

示例5: checkSendButtonEnable

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 显示发送或更多
 *
 * @param editText
 */
private void checkSendButtonEnable(EditText editText) {
    if (isRobotSession) {
        return;
    }
    String textMessage = editText.getText().toString();
    if (!TextUtils.isEmpty(StringUtil.removeBlanks(textMessage)) && editText.hasFocus()) {
        moreFuntionButtonInInputBar.setVisibility(View.GONE);
        sendMessageButtonInInputBar.setVisibility(View.VISIBLE);
    } else {
        sendMessageButtonInInputBar.setVisibility(View.GONE);
        moreFuntionButtonInInputBar.setVisibility(View.VISIBLE);
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:19,代码来源:InputPanel.java


注:本文中的android.widget.EditText.hasFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。