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