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


Java EditText.requestFocus方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:AbstractEditComponent.java

示例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;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:22,代码来源:DialogUtils.java

示例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));
    }
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:27,代码来源:LoginActivity.java

示例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();
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:21,代码来源:MainActivity.java

示例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();
}
 
开发者ID:cyrilmottier,项目名称:QueryHighlighter,代码行数:19,代码来源:MainActivity.java

示例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.
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:10,代码来源:ActivityPlotXYGraph.java

示例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();
    }
}
 
开发者ID:codeccc,项目名称:baselibrary-master,代码行数:20,代码来源:EdittextUtil.java

示例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);
      }
  }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:14,代码来源:AppUtils.java

示例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);

}
 
开发者ID:zhudongya123,项目名称:WechatChatroomHelper,代码行数:9,代码来源:SoftKeyboardUtil.java

示例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();
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:33,代码来源:NewPassword.java

示例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);
		}
	}
}
 
开发者ID:TommyLemon,项目名称:APIJSON-Android-RxJava,代码行数:38,代码来源:EditTextUtil.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:EmoticonsKeyboardUtils.java

示例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;
}
 
开发者ID:GoodieBag,项目名称:Pinview,代码行数:15,代码来源:Pinview.java

示例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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:KeyboardUtils.java

示例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());
    }
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:8,代码来源:ViewUtil.java


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