List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:com.kaytat.simpleprotocolplayer.MainActivity.java
private void hideKb() { InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); View v = getCurrentFocus();/* w w w . j a v a2s. c o m*/ if (v != null) { inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java
/** * Clear search focus, then hide keyboard. *///from w w w .j a v a 2s . co m public void clearSearchFocus() { if (search.hasFocus()) { search.clearFocus(); } InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(search.getWindowToken(), 0); }
From source file:com.cloverstudio.spika.extendables.SpikaActivity.java
protected void hideKeyboard() { InputMethodManager inputMethodManager = (InputMethodManager) this .getSystemService(Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0); }
From source file:li.barter.fragments.AbstractBarterLiFragment.java
/** * Hides the keyboard/* www .ja va2s . c om*/ * * @param view the view from which keyboard was open */ public void hideKeyBoard(View view) { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:com.amazon.appstream.fireclient.ConnectDialogFragment.java
/** * Create callback; performs initial set-up. *///from ww w.j av a 2s .co m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mEmpty.setAlpha(0); final Dialog connectDialog = new Dialog(getActivity()); connectDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); connectDialog.setCanceledOnTouchOutside(false); connectDialog.setCancelable(false); connectDialog.setContentView(R.layout.server_address); connectDialog.getWindow().setBackgroundDrawable(mEmpty); mAddressTitle = (TextView) connectDialog.findViewById(R.id.address_title); mAddressField = (TextView) connectDialog.findViewById(R.id.address); mTextEntryFields = connectDialog.findViewById(R.id.text_entry_fields); mProgressBar = (ProgressBar) connectDialog.findViewById(R.id.progress_bar); mUseHardware = (CheckBox) connectDialog.findViewById(R.id.hardware); mUseHardware.setChecked(false); final CheckBox useAppServerBox = (CheckBox) connectDialog.findViewById(R.id.appserver); useAppServerBox.setChecked(mUseAppServer); useAppServerBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (!mUseAppServer) { mDESServerAddress = mAddressField.getText().toString(); } } else { if (mUseAppServer) { mServerAddress = mAddressField.getText().toString(); } } mUseAppServer = isChecked; updateFields(); } }); mAppIdField = (TextView) connectDialog.findViewById(R.id.appid); mSpace1 = connectDialog.findViewById(R.id.space1); mSpace2 = connectDialog.findViewById(R.id.space2); mAppIdTitle = connectDialog.findViewById(R.id.appid_title); mUserIdTitle = connectDialog.findViewById(R.id.userid_title); if (mAppId != null) { mAppIdField.setText(mAppId); } mUserIdField = (TextView) connectDialog.findViewById(R.id.userid); if (mUsername != null) { mUserIdField.setText(mUsername); } mErrorMessageField = (TextView) connectDialog.findViewById(R.id.error_message); mReconnect = connectDialog.findViewById(R.id.reconnect_fields); mReconnectMessage = (TextView) connectDialog.findViewById(R.id.reconnect_message); final Button connectButton = (Button) connectDialog.findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onConnect(); } }); TextView.OnEditorActionListener listener = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mUserIdField.getWindowToken(), 0); onConnect(); } return true; } }; View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { connectButton.setFocusableInTouchMode(false); } }; mAppIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnEditorActionListener(listener); updateFields(); if (mAddressField.getText().length() == 0) { mAddressField.requestFocus(); connectButton.setFocusableInTouchMode(false); } else { connectButton.requestFocus(); } if (mReconnectMessageString != null) { reconnecting(mReconnectMessageString); mReconnectMessageString = null; } return connectDialog; }
From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java
@Override public void onDetach() { super.onDetach(); if (searchBox != null) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0); }/*from w w w . j a v a 2 s.c o m*/ }
From source file:prince.app.ccm.Fragment_Log.java
private void initView(View view) { // Set up the login form. mUserEditText = (EditText) view.findViewById(R.id.username); // addFocusListener(mUserEditText); mPasswordEditText = (EditText) view.findViewById(R.id.password); // addFocusListener(mPasswordEditText); mPasswordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override// w w w .j a v a 2 s .c o m public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.user_login || id == EditorInfo.IME_NULL) { if (!Tool.getInstance().isConnection()) Toast.makeText(getActivity(), "No network connection!", Toast.LENGTH_SHORT).show(); else { attemptLogin(); return true; } } return false; } }); mLoginFormView = view.findViewById(R.id.login_form); mLoginStatusView = view.findViewById(R.id.login_progress); view.findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); attemptLogin(); } }); mRemind = (CheckBox) view.findViewById(R.id.box_remember); if (Tool.getInstance().getBolPref(Util.REMIND)) { mRemind.setChecked(true); mUserEditText.setText(""); mPasswordEditText.setText(""); mUserEditText.append(Tool.getInstance().getStringPref(Util.USER)); mPasswordEditText.append(Tool.getInstance().getStringPref(Util.PASSWORD)); } mShowPassword = (CheckBox) view.findViewById(R.id.box_reveal); mShowPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mPasswordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); } else { mPasswordEditText .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } if (mPasswordEditText.hasFocus()) { String temp = mPasswordEditText.getText().toString().trim(); mPasswordEditText.setText(""); mPasswordEditText.append(temp); } } }); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void getSessionIdAndLogin(final String rollNo, final String password, AumsServer.Server server) { aums.logout();//from w w w. jav a 2 s . c om aums.switchServer(server); dialog.setMessage("Starting a new session ..."); aums.getSessionId(new SessionResponse() { @Override public void onSuccess(String formAction, String lt) { dialog.setMessage("Logging into AUMS ..."); aums.login(rollNo, password, formAction, lt, new LoginResponse() { @Override public void onSuccess(String name, String rollNo) { isLoggedIn = true; setupLayout(R.layout.activity_aums_profile, Color.parseColor("#e91e63")); dialog.dismiss(); TextView nameView = (TextView) findViewById(R.id.student_name); TextView rollNoView = (TextView) findViewById(R.id.student_roll_no); if (getCurrentFocus() != null) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } nameView.setText(WordUtils.capitalizeFully(name)); rollNoView.setText(rollNo); getSupportActionBar().setSubtitle("Logged in as " + WordUtils.capitalizeFully(name)); loadCgpa(); loadPhoto(); Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "AUMS"); bundle.putString(FirebaseAnalytics.Param.CHARACTER, name + " - " + rollNo); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "screen"); tracker.logEvent(FirebaseAnalytics.Event.LOGIN, bundle); } @Override public void onFailedAuthentication() { dialog.dismiss(); createSnackbar("Credentials were incorrect."); } @Override public void onServerChanged(AumsServer.Server server) { dialog.setMessage("Switching server ..."); getSessionIdAndLogin(rollNo, password, server); } @Override public void onFailure(Throwable throwable) { dialog.dismiss(); createSnackbar("An error occurred while connecting to the server."); Ln.e(throwable); } @Override public void onSiteStructureChange() { dialog.dismiss(); createSnackbar("Site's structure has changed. Reported to the developer."); } }); } @Override public void onFailure(Throwable throwable) { dialog.dismiss(); createSnackbar("An error occurred while connecting to the server."); Ln.e(throwable); } @Override public void onSiteStructureChange() { dialog.dismiss(); createSnackbar("Site's structure has changed. Reported to the developer."); } }); }
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Navigate to the new page/* ww w.j ava2 s . c om*/ * * @param url * to load */ private void navigate(String url) { InputMethodManager imm = (InputMethodManager) this.cordova.getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0); if (!url.startsWith("http") && !url.startsWith("file:")) { this.webview.loadUrl("http://" + url); } else { this.webview.loadUrl(url); } this.webview.requestFocus(); }