List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:org.zirco.ui.activities.MainActivity.java
/** * Hide the keyboard./*from www . j a v a 2s.co m*/ * @param delayedHideToolbars If True, will start a runnable to delay tool bars hiding. If False, tool bars are hidden immediatly. */ private void hideKeyboard(boolean delayedHideToolbars) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mUrlEditText.getWindowToken(), 0); if (mUrlBarVisible) { if (delayedHideToolbars) { startToolbarsHideRunnable(); } else { setToolbarsVisibility(false); } } }
From source file:org.cryptsecure.Utility.java
/** * Hide the keyboard explicitly for a text input field known to be able to * get the focus.//from www. j a v a2 s . co m * * @param textInput * the text input */ public static void hideKeyboardExplicit(EditText textInput) { // hide keyboard explicitly InputMethodManager imm = (InputMethodManager) textInput.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); // imm.restartInput(addUserName); imm.hideSoftInputFromWindow(textInput.getWindowToken(), 0); }
From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java
@Override protected void onStart() { // ?onstart super.onStart();// updateDisplay();// ? Intent intentr = getIntent();//from w w w.j a va2 s .c o m userid = intentr.getIntExtra("cwp.id", 100000001); bundle = intentr.getExtras();// ??Bundle if (bundle.containsKey("cwp.message")) { strInfos = bundle.getStringArray("cwp.message");// ?Bundle? strno = strInfos[0];// id strType = strInfos[1];// typemode = "ModifyInPActivity"; if (strType.equals("btnininfo")) { // type = "income"; } else { type = "pay"; } } keyBoard = new KeyboardUtil(this, this, txtMoney, typemode); // if (bundle.containsKey("cwp.voice")) { // ? if (firstin) { bottom_empty.setVisibility(View.GONE); bottom_full.setVisibility(View.VISIBLE); dialogShowUtil.dialogShow("rotatebottom", "first", "", ""); firstin = false; } } if (bundle.containsKey("cwp.photo")) {// ?? if (firstin) { bottom_empty.setVisibility(View.GONE); bottom_full.setVisibility(View.VISIBLE); Intent intent = new Intent(AddPayActivity.this, PublishedActivity.class); intent.putExtra("cwp.id", userid); intent.putExtra("cwp.photo", "photo"); startActivityForResult(intent, 102); firstin = false; } } if (bundle.containsKey("keyboard")) { // ? if (keycount) { InputMethodManager imm = (InputMethodManager) getSystemService( AddPayActivity.this.INPUT_METHOD_SERVICE); // imm.hideSoftInputFromWindow(txtMoney.getWindowToken(), 0); // ?? keyBoard.showKeyboard(); keycount = false; } } updatetype(); txtTime.setOnTouchListener(new OnTouchListener() { // ?? @Override public boolean onTouch(View v, MotionEvent event) { showDialog(DATE_DIALOG_ID);// ? return false; } }); txtMoney.setOnTouchListener(new OnTouchListener() { // ? @Override public boolean onTouch(View v, MotionEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService( AddPayActivity.this.INPUT_METHOD_SERVICE); // imm.hideSoftInputFromWindow(txtMoney.getWindowToken(), 0); // ?? keyBoard.showKeyboard(); return false; } }); //TODO btnVoice.setOnClickListener(new OnClickListener() {// ? @Override public void onClick(View v) { dialogShowUtil.dialogShow("rotatebottom", "first", "", ""); //VoiceRecognition(); } }); // ?? btnSaveButton.setOnClickListener(new OnClickListener() { private String textreAddres; private String textreMark; @SuppressLint("NewApi") @Override public void onClick(View arg0) { textreAddres = txtAddress.getText().toString(); textreMark = txtMark.getText().toString(); if (textphoto == null) { textphoto = ""; } if (typemode == "add") { // ? String strMoney = txtMoney.getText().toString();// ?? if (type == "pay") { // if (!strMoney.isEmpty()) {// ?? // InaccountDAO PayDAO payDAO = new PayDAO(AddPayActivity.this); // Tb_inaccount Tb_pay tb_pay = new Tb_pay(userid, payDAO.getMaxNo(userid) + 1, get2Double(strMoney), setTimeFormat(null), (spType.getSelectedItemPosition() + 1), textreAddres, textreMark, textphoto); payDAO.add(tb_pay);// ? Toast.makeText(AddPayActivity.this, "???", Toast.LENGTH_SHORT).show(); gotoback(); } else { Toast.makeText(AddPayActivity.this, "??", Toast.LENGTH_SHORT) .show(); } } else { // if (!strMoney.isEmpty()) {// ?? // InaccountDAO IncomeDAO incomeDAO = new IncomeDAO(AddPayActivity.this); // Tb_inaccount Tb_income tb_income = new Tb_income(userid, payDAO.getMaxNo(userid) + 1, get2Double(strMoney), setTimeFormat(null), (spType.getSelectedItemPosition() + 1), // txtInhandler.getText().toString(), textreAddres, textreMark, textphoto, ""); incomeDAO.add(tb_income);// ? // ??? Toast.makeText(AddPayActivity.this, "???", Toast.LENGTH_SHORT).show(); gotoback(); } else { Toast.makeText(AddPayActivity.this, "??", Toast.LENGTH_SHORT) .show(); } } } else { // ? if (type == "pay") { // if (!txtMoney.getText().toString().isEmpty()) {// ?? Tb_pay tb_pay = new Tb_pay(); // Tb_pay tb_pay.set_id(userid); // userid tb_pay.setNo(Integer.parseInt(strno)); // ? tb_pay.setMoney(get2Double(txtMoney.getText().toString()));// ? tb_pay.setTime(setTimeFormat(txtTime.getText().toString()));// tb_pay.setType(spType.getSelectedItemPosition() + 1);// tb_pay.setAddress(textreAddres);// tb_pay.setMark(textreMark);// tb_pay.setPhoto(textphoto);// payDAO.update(tb_pay);// ? Toast.makeText(AddPayActivity.this, "???", Toast.LENGTH_SHORT) .show(); gotoback(); } else { Toast.makeText(AddPayActivity.this, "??", Toast.LENGTH_SHORT) .show(); } } else { // if (!txtMoney.getText().toString().isEmpty()) {// ?? Tb_income tb_income = new Tb_income();// Tb_income tb_income.set_id(userid);// ? tb_income.setNo(Integer.parseInt(strno));// ? tb_income.setMoney(get2Double(txtMoney.getText().toString()));// ? tb_income.setTime(setTimeFormat(txtTime.getText().toString()));// tb_income.setType(spType.getSelectedItemPosition() + 1);// tb_income.setHandler(textreAddres);// tb_income.setMark(textreMark);// tb_income.setPhoto(textphoto);// incomeDAO.update(tb_income);// ? Toast.makeText(AddPayActivity.this, "???", Toast.LENGTH_SHORT) .show(); gotoback(); } else { Toast.makeText(AddPayActivity.this, "??", Toast.LENGTH_SHORT) .show(); } } } } }); btnCancelButton.setOnClickListener(new OnClickListener() {// ??? @Override public void onClick(View arg0) { if (typemode == "add") { // ? txtMoney.setText("");// ? txtMoney.setHint("0.00");// ??? txtTime.setText("");// txtAddress.setText("");// ? txtMark.setText("");// // txtInhandler.setText("");// spType.setSelection(0);// gotoback(); } else { // ? if (type == "pay") { // payDAO.detele(userid, Integer.parseInt(strno));// ??? gotoback(); } else { // incomeDAO.detele(userid, Integer.parseInt(strno));// ??? gotoback(); } Toast.makeText(AddPayActivity.this, "???", Toast.LENGTH_SHORT).show(); } } }); }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Click handler for the list items. Will create the appropriate edit * box for the clicked setting./*w w w . j av a 2 s. co m*/ */ @Override public void onListItemClick(ListView oParent, View v, int iPos, long id) { final ListView oParentListView = oParent; final SettingsListItem oItem = m_filteredSettings.get(iPos); if (oItem instanceof ChoiceSettingsListItem) { final ChoiceSettingsListItem oChoiceItem = (ChoiceSettingsListItem) oItem; // Show dialog new AlertDialog.Builder(SettingsActivity.this) .setTitle(getString(R.string.Label_Edit) + " " + oItem.m_sLabel) .setSingleChoiceItems(oChoiceItem.m_asText, oChoiceItem.m_iSelectedItem, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { oChoiceItem.select(whichButton); if (oItem.m_iPropId == PropertyID.CONNECTION_AUTO_REGISTRATION_HINT) { m_iRegistrationMethod = (Integer) oChoiceItem.m_oValue; if (m_iRegistrationMethod == Settings.REGISTRATION_METHOD.CERTIFICATE) { handleLocalCertificateSelection(); } } // refresh in ui refreshList(); oParentListView.invalidate(); // Close dialog dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Close dialog dialog.dismiss(); } }).show(); } else { // inflate the xml layout final View oView = m_oInflater.inflate(R.layout.settings_edit, null); TextView tv = (TextView) oView.findViewById(R.id.TextViewEditSettings); if (tv != null) tv.setText(getItemLabel(oItem)); // set value tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); if (tv != null) tv.setText(oItem.m_oValue.toString()); // special input validator for integers if (oItem.m_oValue instanceof Integer) tv.setInputType(InputType.TYPE_CLASS_NUMBER); if (oItem.m_bPassword) tv.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // show dialog, valid value when user clicks ok button new AlertDialog.Builder(this).setTitle(getString(R.string.Label_Edit) + " " + getItemLabel(oItem)) .setView(oView).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); String sText = tv.getText().toString(); if (oItem.m_oValue instanceof Integer) oItem.m_oValue = Integer.parseInt(sText); else if (oItem.m_oValue instanceof Boolean) oItem.m_oValue = Boolean.parseBoolean(sText); else oItem.m_oValue = sText; InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); //validate the input value if (!validateField(oItem)) { // validation failed, reset to original value oItem.m_oValue = oItem.m_oOrigValue; showValidationErrorDialog(oItem.m_sLabel); } else { // refresh in ui refreshList(); oParentListView.invalidate(); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); dialog.dismiss(); } }).show(); } }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** * Constructor/*from w w w. j a v a 2 s . com*/ */ @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); acList = new ArrayList<InitDestFrame>(); r = getResources(); //Calls the initAutoComplete method, adding the autocomplete listeners to acTo and acFrom initAutocomplete(); //Calls the initAddDestButton method, adding the driving through button initAddDestButton(); //Sets hasDrawn to false hasDrawn = false; Bundle extras = getIntent().getExtras(); if (extras != null) { inEditMode = extras.getBoolean("editMode"); positionOfRoute = extras.getInt("routePosition"); } //Hides the checkbox chk_saveRoute = (CheckBox) findViewById(R.id.checkBoxSave); chk_saveRoute.setVisibility(8); //Initialises the draw/next button final Button button = ((Button) findViewById(R.id.btnChooseRoute)); //Adjustments to the gui if in editmode if (inEditMode) { chk_saveRoute.setVisibility(View.GONE); button.setText("Update the route"); button.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); fillFieldsInEdit(); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { createInputDialog("Route", "Insert name of Route", false); } }); } else { button.setText("Show on map"); button.setEnabled(false); } //Initialises the textviews and the clear buttons final AutoCompleteTextView acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom); final AutoCompleteTextView acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo); ImageView bClearFrom = ((ImageView) findViewById(R.id.etGoingFromClearIcon)); ImageView bClearTo = ((ImageView) findViewById(R.id.etGoingToClearIcon)); //If map is drawn fill the textviews if (selectedRoute.getMapPoints().size() != 0) { fillFieldsOnClick(); } /** * onClickListener on the clearButton on the acFrom field {@link OnClickListener()} */ //Adds onClickListener to the clearbutton on the acFrom field bClearFrom.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { acFrom.setText(""); button.setEnabled(false); button.setText("Show on Map"); } }); /** * onClickListener on the clearButton on the acTo field {@link OnClickListener} */ //Adds onClickListener to the clearbutton on the acTo field bClearTo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { acTo.setText(""); button.setEnabled(false); button.setText("Show on Map"); } }); /** * TextWatcher to the acFrom {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()} */ //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality acFrom.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { hasDrawn = false; if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) { button.setEnabled(true); button.setText("Show on Map"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { button.setEnabled(true); button.setText("Show on map"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); } else if (inEditMode) { } else { button.setText("Show on map"); button.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); /** * TextWatcher to the acTo {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()} */ //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality acTo.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { hasDrawn = false; if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == false) { button.setEnabled(true); button.setText("Show on Map"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { button.setEnabled(true); button.setText("Show on map"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); } else if (inEditMode) { } else { button.setText("Show on map"); button.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); /** * onClickListener on the button(draw/next) {@link OnClickListener} */ //adds the onclickListener to the draw/next button button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) { button.setText("Next"); createOneTimeJourney(); } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) { mapView.getOverlays().clear(); createMap(); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { mapView.getOverlays().clear(); createMap(); button.setText("Next"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { } else if (inEditMode) { createInputDialog("Route", "Insert name of Route", false); button.setText("Next"); } else { } } }); }
From source file:co.taqat.call.ChatFragment.java
@Override public void onPause() { message.removeTextChangedListener(textWatcher); removeVirtualKeyboardVisiblityListener(); LinphoneService.instance().removeMessageNotification(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.removeListener(mListener);/*from w ww .java 2s .com*/ } LinphoneManager.removeListener(this); onSaveInstanceState(getArguments()); //Hide keybord InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(message.getWindowToken(), 0); super.onPause(); }
From source file:com.fvd.nimbus.BrowseActivity.java
void hideKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(findViewById(R.id.etAddess).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w ww . jav a2s . c o m*/ }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
public void initSearchbar() { final ListView searchListView = (ListView) mainArView.findViewById(R.id.ar_mixview_search_list); searchbar = (LinearLayout) mainArView.findViewById(R.id.ar_mixview_searchbar); hideSearchbar = (Button) mainArView.findViewById(R.id.ar_mixview_hide_searchbar); searchBtn = (Button) mainArView.findViewById(R.id.ar_mixview_search); searchBtn.setOnClickListener(new View.OnClickListener() { @Override//w ww. ja v a 2 s .c o m public void onClick(View view) { parentButtonView.setVisibility(View.GONE); searchbar.setVisibility(View.VISIBLE); } }); hideSearchbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { searchbar.setVisibility(View.GONE); parentButtonView.setVisibility(View.VISIBLE); } }); searchText = (EditText) mainArView.findViewById(R.id.ar_mixview_search_text); searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, android.view.KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_SEARCH: String queryString = searchText.getText().toString(); Intent intent = new Intent(context, SearchKeywordListActivity.class); intent.putExtra("searchName", queryString); InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mainArView.getWindowToken(), 0); mainArView.setVisibility(View.GONE); ((Activity) context).startActivityForResult(intent, SEARCH_LIST); break; default: Toast.makeText(context, "", Toast.LENGTH_LONG).show(); return false; } return true; } }); TextWatcher watcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(final CharSequence charSequence, int i, int i1, int i2) { new Thread(new Runnable() { @Override public void run() { String queryString = searchText.getText().toString(); try { List<ARMarker> searchList = null; String encodedQueryString = URLEncoder.encode(queryString, "UTF-8"); String tempCallbackUrl = "http://ac.map.naver.com/ac?q=" + encodedQueryString + "&st=10&r_lt=10&r_format=json"; String rawData = new NaverHttpHandler().execute(tempCallbackUrl).get(); Log.i("rawData", rawData); JSONObject root = new JSONObject(rawData); JSONArray dataArray = root.getJSONArray("items"); JSONArray locationData = dataArray.getJSONArray(0); Log.i("dataArray", locationData.toString()); final ArrayList<String> list = new ArrayList<>(); for (int index = 0; index < locationData.length(); index++) list.add(locationData.getString(index).substring(2, locationData.getString(index).length() - 2)); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { SearchViewAdapter adapter = new SearchViewAdapter(inflater); adapter.setDataList(list); adapter.setCurrentText(charSequence.toString()); searchListView.setAdapter(adapter); searchListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String queryString = list.get(i); searchText.setText(queryString); } }); } }); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }).start(); } @Override public void afterTextChanged(Editable editable) { } }; searchText.addTextChangedListener(watcher); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
private void setFinishHandler() { mWiz.setOnFinish(new SafeRunnable() { private void startMainActivity() { Intent intent = new Intent(RegistrationActivity2.this, MainActivity.class); intent.setAction(MainActivity.ACTION_REGISTERED); startActivity(intent);//from ww w .j av a 2 s . c o m RegistrationActivity2.this.finish(); } private void showPopup(Configuration cfg) { if (mDiscoveredBeacons != null) { Intent intent = new Intent(RegistrationActivity2.this, MainActivity.class); intent.setAction(MainActivity.ACTION_SHOW_DETECTED_BEACONS); intent.putExtra(DetectedBeaconActivity.EXTRA_DETECTED_BEACONS, mDiscoveredBeacons); intent.putExtra(DetectedBeaconActivity.EXTRA_AGE_AND_GENDER_SET, mAgeAndGenderSet); intent.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(intent); RegistrationActivity2.this.finish(); return; } if (AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE && !mAgeAndGenderSet) { Intent intent = new Intent(RegistrationActivity2.this, MainActivity.class); intent.setAction(MainActivity.ACTION_COMPLETE_PROFILE); intent.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(intent); RegistrationActivity2.this.finish(); return; } startMainActivity(); } @Override protected void safeRun() throws Exception { T.UI(); if (mEnterPinEditText != null) { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(mEnterPinEditText.getWindowToken(), 0); } Configuration cfg = mService.getConfigurationProvider() .getConfiguration(RegistrationWizard2.CONFIGKEY); if (cfg != null && cfg.get(INVITOR_SECRET_CONFIGKEY, null) != null && cfg.get(INVITOR_CODE_CONFIGKEY, null) != null) { // User pressed an invitation link with secret startMainActivity(); } else { showPopup(cfg); } } }); }