本文整理汇总了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);
}
}