Java Code Examples for android.widget.EditText#clearFocus()
The following examples show how to use
android.widget.EditText#clearFocus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From HtmlNative with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSharedPreference = getSharedPreferences("htmlnative-demo", MODE_PRIVATE); String url = mSharedPreference.getString("url", ""); mContainer = (RelativeLayout) findViewById(R.id.relative_view); mSearch = (EditText) findViewById(R.id.search_editbox); mSearch.setText(url); mGo = (ImageButton) findViewById(R.id.search_go_btn); mGo.setOnClickListener(this); mLoader = new RemoteViewLoader(this); mSearch.clearFocus(); }
Example 2
Source File: NiboOriginDestinationPickerFragment.java From Nibo with MIT License | 6 votes |
@NonNull private View.OnTouchListener getClearListener(final EditText editText) { return new View.OnTouchListener() { final int DRAWABLE_LEFT = 0; final int DRAWABLE_TOP = 1; final int DRAWABLE_RIGHT = 2; final int DRAWABLE_BOTTOM = 3; @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { int leftEdgeOfRightDrawable = editText.getRight() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width(); // when EditBox has padding, adjust leftEdge like // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right); if (event.getRawX() >= leftEdgeOfRightDrawable) { // clicked on clear icon editText.setText(""); editText.clearFocus(); return true; } } return false; } }; }
Example 3
Source File: CommentActivity.java From android-project-wo2b with Apache License 2.0 | 6 votes |
@Override protected void initView() { if (!TextUtils.isEmpty(mTitle)) { setActionBarTitle(mTitle); } send_comment = (TextView) findViewById(R.id.send_comment); et_content = (EditText) findViewById(R.id.et_content); send_comment.setOnClickListener(this); et_content.setSelected(false); et_content.clearFocus(); //ViewUtils.hideSoftInput(this); //et_content.clearFocus(); }
Example 4
Source File: RegisterActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * requests focus on a {@link EditText} allowing to see its title too. It is used to set focus on the * first question with error. * * @param et field we want to set focus in. * @param tv_id id of the {@link TextView} which is the title of et. */ private void focusFirstError(EditText et, int tv_id) { et.clearFocus(); // requestRectangle does not work properly if et is focused et.requestFocus(); TextView title = (TextView) findViewById(tv_id); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) title.getLayoutParams(); Rect rect = new Rect(0, -lp.topMargin, title.getWidth(), title.getHeight()); title.requestRectangleOnScreen(rect); }
Example 5
Source File: ProfileActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * requests focus on a {@link EditText} allowing to see its title too. It is used to set focus * on the first question with error. * * @param et field we want to set focus in. * @param tv_id id of the {@link TextView} which is the title of et. */ private void focusFirstError(EditText et, int tv_id) { et.clearFocus(); // requestRectangle does not work properly if et is already focused et.requestFocus(); TextView title = (TextView) findViewById(tv_id); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) title.getLayoutParams(); Rect rect = new Rect(0, -lp.topMargin, title.getWidth(), title.getHeight()); title.requestRectangleOnScreen(rect); }
Example 6
Source File: HomeActivity.java From Passbook with Apache License 2.0 | 5 votes |
public void onConfirm(View view) { String password = mPwdEdit.getText().toString(); if(password.length() < 1) { Application.showToast(this, R.string.pwd_wrong, Toast.LENGTH_SHORT); return; } if(mStage == SET_PWD) { EditText et_confirm = findViewById(R.id.confirm); if(password.equals(et_confirm.getText().toString())) { et_confirm.clearFocus(); InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(et_confirm.getWindowToken(), 0); } mApp.setPassword(password, true); new InitTask(this).execute(); } else { et_confirm.setText(""); mPwdEdit.setText(""); Application.showToast(this, R.string.pwd_unmatch, Toast.LENGTH_SHORT); } } else { mApp.setPassword(password, false); new DecryptTask(mApp.getData(this), mApp.getAppHeaderData(this), this).execute(password); } }
Example 7
Source File: AMUtils.java From sealtalk-android with MIT License | 5 votes |
public static void onInactive(Context context, EditText et) { if (et == null) return; et.clearFocus(); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et.getWindowToken(), 0); }
Example 8
Source File: AMUtils.java From sealrtc-android with MIT License | 5 votes |
public static void onInactive(Context context, EditText et) { if (et == null) return; et.clearFocus(); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et.getWindowToken(), 0); }
Example 9
Source File: SubjectBaseActivity.java From Primary with GNU General Public License v3.0 | 5 votes |
private void showSoftKeyboard(final EditText view, ViewGroup keypadarea, String defaultInput) { view.clearFocus(); if (defaultInput != null) { view.setText(defaultInput); view.setSelection(defaultInput.length()); } boolean isnumeric = ((view.getInputType() & InputType.TYPE_CLASS_NUMBER) == InputType.TYPE_CLASS_NUMBER) || ((view.getInputType() & InputType.TYPE_CLASS_DATETIME) == InputType.TYPE_CLASS_DATETIME); int whichkeyboard = Integer.parseInt(appPreferences.getString("keyboard_preference", "1")); int whichkeypad = Integer.parseInt(appPreferences.getString("keypad_preference", "1")); boolean gkeyboardAvail = getResources().getBoolean(R.bool.game_keyboard_available); boolean gkeypadAvail = getResources().getBoolean(R.bool.game_keypad_available); if (isnumeric && gkeypadAvail && whichkeypad == 1 && keypadarea != null) { Keyboard.showNumberpad(this, view, keypadarea, mNumpadkeyMap); } else if (!isnumeric && gkeyboardAvail && whichkeyboard == 1 && keypadarea != null) { Keyboard.showKeyboard(this, view, keypadarea, mKeyboardkeyMap); } else if (whichkeypad == 2 || whichkeyboard == 2 || (isnumeric && !gkeypadAvail) || (!isnumeric && !gkeyboardAvail)) { showSystemKeyboard(view); } }
Example 10
Source File: RxKeyboardTool.java From RxTools-master with Apache License 2.0 | 5 votes |
/** * 动态隐藏软键盘 * * @param context 上下文 * @param edit 输入框 */ public static void hideSoftInput(Context context, EditText edit) { edit.clearFocus(); InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0); }
Example 11
Source File: KeyboardUtils.java From Ticket-Analysis with MIT License | 5 votes |
/** * 动态隐藏软键盘 */ public static void hideSoftInput(Context context, EditText edit) { edit.clearFocus(); InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0); }
Example 12
Source File: X8FcExpSettingController.java From FimiX8-RE with MIT License | 5 votes |
public void onError(EditText v, int errorCode, String errorMsg) { X8ToastUtil.showToast(this.mContext, this.contentView.getContext().getString(R.string.x8_fc_exp_error_tip), 0); double curValue = 0.0d; int i = v.getId(); if (i == R.id.edt_to_up_down) { curValue = this.cvToUpDown.getCurValue(); } else if (i == R.id.edt_to_left_right) { curValue = this.cvToLeftRight.getCurValue(); } else if (i == R.id.edt_to_go_back) { curValue = this.cvToGoBack.getCurValue(); } v.setText(String.valueOf(curValue)); v.clearFocus(); }
Example 13
Source File: SystemUtil.java From Android with MIT License | 4 votes |
/** * Hide the keyboard * @param context * @param editText */ public static void hideKeyBoard(Context context,EditText editText){ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); editText.clearFocus(); }
Example 14
Source File: SoftKeyboardUtil.java From emoji-keyboard with Apache License 2.0 | 4 votes |
public static void dismissSoftKeyboard(Context context, EditText editText) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); editText.clearFocus(); }
Example 15
Source File: HomeActivity.java From DistroHopper with GNU General Public License v3.0 | 4 votes |
public void closeDash () { if (! this.isDashOpened) { return; } if (modeCustomise) { Intent intent = this.getIntent (); intent.putExtra ("customise", false); this.finish (); this.startActivity (intent); return; } EditText etDashSearch = this.viewFinder.get(R.id.etDashSearch); this.llDash.setVisibility (View.GONE); this.wpWallpaper.unblur (); etDashSearch.setText (""); etDashSearch.clearFocus (); if (this.getResources ().getInteger (HomeActivity.theme.panel_close_location) != -1) this.ibPanelDashClose.setVisibility (View.INVISIBLE); SharedPreferences prefs = this.getSharedPreferences (); this.llPanel.setAlpha ((float) prefs.getInt (Preference.PANEL_OPACITY.getName(), 100) / 100F); if (this.getResources ().getBoolean (HomeActivity.theme.panel_background_dynamic_when_dash_opened)) { this.llPanel.setBackgroundResource (HomeActivity.theme.panel_background); if (Build.VERSION.SDK_INT >= 19) { LinearLayout llStatusBar = this.viewFinder.get(R.id.llStatusBar); llStatusBar.setBackgroundColor (this.getResources ().getColor (android.R.color.black)); } } InputMethodManager imm = (InputMethodManager) this.getSystemService (Context.INPUT_METHOD_SERVICE); if (imm != null) imm.hideSoftInputFromWindow (this.getWindow ().getDecorView ().getRootView ().getWindowToken (), 0); this.flWallpaperOverlay.setVisibility (View.VISIBLE); this.flWallpaperOverlayWhenDashOpened.setVisibility (View.INVISIBLE); this.isDashOpened = false; }
Example 16
Source File: FileEditorActivity.java From Android-PreferencesManager with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle arg0) { setTheme(App.theme.theme); super.onCreate(arg0); setContentView(R.layout.activity_file_editor); getSupportActionBar().setDisplayHomeAsUpEnabled(true); Bundle b = getIntent().getExtras(); if (b == null) { finish(); return; } Picasso.with(this).load(b.<Uri>getParcelable(PreferencesFragment.ARG_ICON_URI)).error(R.drawable.ic_launcher).into((android.widget.ImageView) findViewById(android.R.id.home)); mFile = b.getString(PreferencesFragment.ARG_FILE); mTitle = Utils.extractFileName(mFile); mPackageName = b.getString(PreferencesFragment.ARG_PACKAGE_NAME); mEditText = (EditText) findViewById(R.id.editText); //Hack to prevent EditText to request focus when the Activity is created mEditText.post(new Runnable() { @Override public void run() { mEditText.setFocusable(true); mEditText.setFocusableInTouchMode(true); } }); if (arg0 == null) { mEditText.setText(Utils.readFile(mFile)); mColorTheme = ColorThemeEnum.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString(KEY_COLOR_THEME, ColorThemeEnum.ECLIPSE.name())); setXmlFontSize(XmlFontSize.generateSize(PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_FONT_SIZE, XmlFontSize.MEDIUM.getSize()))); } else { mHasContentChanged = arg0.getBoolean(KEY_HAS_CONTENT_CHANGED, false); mNeedUpdateOnActivityFinish = arg0.getBoolean(KEY_NEED_UPDATE_ON_ACTIVITY_FINISH, false); if (mNeedUpdateOnActivityFinish) { setResult(RESULT_OK); } mColorTheme = ColorThemeEnum.valueOf(arg0.getString(KEY_COLOR_THEME)); setXmlFontSize(XmlFontSize.generateSize(arg0.getInt(KEY_FONT_SIZE))); } mXmlColorTheme = XmlColorTheme.createTheme(getResources(), mColorTheme); updateTitle(); invalidateOptionsMenu(); highlightXMLText(mEditText.getText()); mEditText.clearFocus(); }
Example 17
Source File: MainActivity.java From azure-notificationhubs-android with Apache License 2.0 | 4 votes |
private void updatePushToken(String value) { EditText editPushToken = findViewById(R.id.editPushToken); editPushToken.setText(value); editPushToken.clearFocus(); }
Example 18
Source File: MainActivity.java From azure-notificationhubs-android with Apache License 2.0 | 4 votes |
private void updateRegistrationID(String value) { EditText editRegistrationID = findViewById(R.id.editRegistrationID); editRegistrationID.setText(value); editRegistrationID.clearFocus(); }
Example 19
Source File: CommonUtil.java From Yuan-SxMusic with Apache License 2.0 | 2 votes |
/** * 关闭软键盘 * * @param mEditText 输入框 * @param context 上下文 */ public static void closeKeybord(EditText mEditText, Context context) { mEditText.clearFocus(); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); }
Example 20
Source File: KeyboardUtil.java From timecat with Apache License 2.0 | 2 votes |
/** * 针对于EditText ,失去焦点,隐藏软件盘 * * @param edit */ public void hideKeyboard(EditText edit) { edit.clearFocus(); imm.hideSoftInputFromWindow(edit.getWindowToken(), 0); }