本文整理汇总了Java中android.widget.EditText.requestFocus方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.requestFocus方法的具体用法?Java EditText.requestFocus怎么用?Java EditText.requestFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.requestFocus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAutofocus
import android.widget.EditText; //导入方法依赖的package包/类
@WXComponentProp(name = Constants.Name.AUTOFOCUS)
public void setAutofocus(boolean autofocus) {
if (getHostView() == null) {
return;
}
mAutoFocus = autofocus;
EditText inputView = getHostView();
if (mAutoFocus) {
inputView.setFocusable(true);
inputView.requestFocus();
inputView.setFocusableInTouchMode(true);
inputView.postDelayed(new Runnable() {
@Override
public void run() {
showSoftKeyboard();
}
}, 16);
} else {
inputView.postDelayed(new Runnable() {
@Override
public void run() {
hideSoftKeyboard();
}
}, 16);
}
}
示例2: onCreateView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
chatSDKUiHelper = ChatSDKUiHelper.getInstance().get(getActivity());
View view = inflater.inflate(R.layout.chat_sdk_dialog_edit_text, container);
mEditText = (EditText) view.findViewById(R.id.et_enter);
getDialog().setTitle(dialogTitle);
// Show soft keyboard automatically
mEditText.requestFocus();
getDialog().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
// Listen to Done press on the keyboard.
mEditText.setOnEditorActionListener(this);
return view;
}
示例3: loginErrorMessage
import android.widget.EditText; //导入方法依赖的package包/类
private void loginErrorMessage(String errorMessage, EditText email, EditText password) {
if(errorMessage.equals(getString(R.string.msg_len_email_error_message))){
email.requestFocus();
email.setError("Email inválido. Tente novamente");
}
if(errorMessage.equals(getString(R.string.msg_special_characters_email_error_message))){
email.requestFocus();
email.setError("Email inválido. Tente novamente");
}
if(errorMessage.equals(getString(R.string.msg_null_email_error_message))){
email.requestFocus();
email.setError(getString(R.string.msg_null_email_error_message));
}
if(errorMessage.equals(getString(R.string.msg_len_password_error_message))){
password.requestFocus();
password.setError("Senha inválida. Tente Novamente");
}
if(errorMessage.equals(getString(R.string.msg_null_password_error_message))){
password.requestFocus();
password.setError(getString(R.string.msg_null_password_error_message));
}
}
示例4: onShowTab
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onShowTab(@NonNull final Context context,
@NonNull final TabSwitcher tabSwitcher, @NonNull final View view,
@NonNull final Tab tab, final int index, final int viewType,
@Nullable final Bundle savedInstanceState) {
TextView textView = findViewById(android.R.id.title);
textView.setText(tab.getTitle());
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setVisibility(tabSwitcher.isSwitcherShown() ? View.GONE : View.VISIBLE);
if (viewType != 0) {
EditText editText = findViewById(android.R.id.edit);
if (savedInstanceState == null) {
editText.setText(null);
}
editText.requestFocus();
}
}
示例5: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAdapter = new CheesesAdapter();
final ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(mAdapter);
final ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.search_view);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
final EditText editText = (EditText) actionBar.getCustomView();
editText.addTextChangedListener(mTextWatcher);
editText.requestFocus();
}
示例6: refreshCurveDefViewList
import android.widget.EditText; //导入方法依赖的package包/类
public void refreshCurveDefViewList() {
mlayoutCurveListViewHolder.removeAllViews();
for (int idx = 0; idx < mlistCurveSettings.length; idx ++) {
View newCurveDefView = genCurveDefView(idx);
mlayoutCurveListViewHolder.addView(newCurveDefView);
}
EditText edtGraphName = (EditText)findViewById(R.id.graph_name_edit);
edtGraphName.requestFocus(); // if not set new focus, the input from ime may crash.
}
示例7: setEditTextEditable
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 设置EditText是否可编辑
*
* @param editText 要设置的EditText
* @param value 可编辑:true 不可编辑:false
* @author com.tiantian
*/
public static void setEditTextEditable(EditText editText, boolean value)
{
if (value)
{
editText.setFocusableInTouchMode(true);
editText.requestFocus();
} else
{
editText.setFocusableInTouchMode(false);
editText.clearFocus();
}
}
示例8: tryFocusEditText
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 强制聚焦并打开键盘
*
* @param activity
* @param editText
*/
public static void tryFocusEditText(Activity activity, EditText editText) {
if (editText.requestFocus()) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
}
示例9: openKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
public static void openKeyboard(EditText mEditText, Context mContext) {
mEditText.setFocusable(true);
mEditText.setFocusableInTouchMode(true);
mEditText.requestFocus();
InputMethodManager inputManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(mEditText, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
示例10: showAttributeDetail
import android.widget.EditText; //导入方法依赖的package包/类
private void showAttributeDetail(final String attributeType, final String attributeValue) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(attributeType);
final EditText input = new EditText(NewPassword.this);
input.setText(attributeValue);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
input.requestFocus();
builder.setView(input);
builder.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
String newValue = input.getText().toString();
if (!newValue.equals(attributeValue)) {
refreshItemsDisplayed();
}
mUserDialog.dismiss();
} catch (Exception e) {
Log.e(AppUtility.TAG, Log.getStackTraceString(e));
}
}
});
mUserDialog = builder.create();
mUserDialog.show();
}
示例11: showKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
/**显示/隐藏输入法
* @param context
* @param et
* @param toGetWindowTokenView(为null时toGetWindowTokenView = et) 包含et的父View,键盘根据toGetWindowTokenView的位置来弹出/隐藏
* @param show
*/
public static void showKeyboard(Context context, EditText et, View toGetWindowTokenView, boolean show){
if (context == null) {
Log.e(TAG, "showKeyboard context == null >> return;");
return;
}
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);//imm必须与context唯一对应
if (toGetWindowTokenView == null) {
Log.w(TAG, "showKeyboard toGetWindowTokenView == null");
toGetWindowTokenView = et;
}
if (toGetWindowTokenView == null) {
Log.e(TAG, "showKeyboard toGetWindowTokenView == null && et == null >> return;");
return;
}
if (show == false) {
imm.hideSoftInputFromWindow(toGetWindowTokenView.getWindowToken(), 0);
if (et != null) {
et.clearFocus();
}
} else {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
imm.toggleSoftInputFromWindow(toGetWindowTokenView.getWindowToken()
, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
示例12: openSoftKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 开启软键盘
* @param et
*/
public static void openSoftKeyboard(EditText et) {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
InputMethodManager inputManager = (InputMethodManager) et.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(et, 0);
}
}
示例13: requestPinEntryFocus
import android.widget.EditText; //导入方法依赖的package包/类
/**
* Requsets focus on current pin view and opens keyboard if forceKeyboard is enabled.
*
* @return the current focused pin view. It can be used to open softkeyboard manually.
*/
public View requestPinEntryFocus() {
int currentTag = Math.max(0, getIndexOfCurrentFocus());
EditText currentEditText = editTextList.get(currentTag);
if (currentEditText != null) {
currentEditText.requestFocus();
}
openKeyboard();
return currentEditText;
}
示例14: showSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 动态显示软键盘
*
* @param edit 输入框
*/
public static void showSoftInput(EditText edit) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager imm = (InputMethodManager) Utils.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edit, 0);
}
示例15: requestInputMethodIfShow
import android.widget.EditText; //导入方法依赖的package包/类
public static void requestInputMethodIfShow(final EditText view) {
final InputMethodManager imm = (InputMethodManager) MyApplication.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
view.requestFocus();
view.setSelection(view.getText().length(), view.getText().length());
}
}