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