當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。