本文整理匯總了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);
}
示例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);
}
示例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);
}
});
}
}
示例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;
}
}
示例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);
}
}