List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS
int HIDE_NOT_ALWAYS
To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.
Click Source Link
From source file:com.spoiledmilk.ibikecph.favorites.EditFavoriteFragment.java
public void hideKeyboard() { if (textFavoriteName != null) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(textFavoriteName.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }//from www . j av a2 s. c om }
From source file:ca.cs.ualberta.localpost.view.MapsView.java
/** * Called when a marker starts being dragged *///from ww w . j a v a2s .co m @Override public void onMarkerDragStart(Marker marker) { // Minimize the keyboard after the 'Find' button is pressed // Source: http://stackoverflow.com/questions/3400028/close-virtual-keyboard-on-button-press InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:com.example.lowviscam.GalleryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); if (isLight == true) { inflater.inflate(R.menu.gallery, menu); } else {//from w w w .ja v a2 s . com inflater.inflate(R.menu.gallery_dark, menu); } // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { search(query); // First image toast String firstResult; if (numSearchResults == 0) { firstResult = "No results found for " + query + "."; } else { firstResult = "The first image result is titled " + tagList[0]; } SpannableString s = new SpannableString(firstResult); s.setSpan(new TypefaceSpan(GalleryActivity.this, "APHont-Regular_q15c.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Toast.makeText(GalleryActivity.this, s, Toast.LENGTH_LONG).show(); return true; } @Override public boolean onQueryTextChange(String newText) { if (TextUtils.isEmpty(newText)) { search(""); } return true; } public void search(String query) { // hide keyboard InputMethodManager inputManager = (InputMethodManager) GalleryActivity.this .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(GalleryActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // Fetch the {@link LayoutInflater} service so that new views can be created LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Find the {@link GridView} that was already defined in the XML layout GridView gridView = (GridView) findViewById(R.id.grid); try { gridView.setAdapter(new CouponAdapter(inflater, createSearchedCoupons(query))); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); return true; //return super.onCreateOptionsMenu(menu); }
From source file:com.gizwits.framework.activity.BaseActivity.java
/** * ????//from ww w . j a va 2 s .c o m * * @param token */ private void hideSoftInput(IBinder token) { if (token != null) { InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:app.clirnet.com.clirnetapp.activity.LoginActivity.java
private void hideKeyBoard() { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); try {//from w w w . ja v a2 s. c o m inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain.java
private void updateItems() { mServingSizeUpdated.setText("1"); LinearLayout changeServing = (LinearLayout) findViewById(R.id.changeServing); changeServing.setOnClickListener(new View.OnClickListener() { @Override/*from w w w.j a v a 2s. com*/ public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(SaveSearchAddItemActivityMain.this); alert.setTitle("Update Serving Size: "); alert.setMessage("Servings Consumed"); final EditText input = new EditText(SaveSearchAddItemActivityMain.this); input.setText(mServingg.getText().toString()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); input.selectAll(); input.setGravity(Gravity.CENTER_HORIZONTAL); alert.setView(input, 64, 0, 64, 0); alert.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double values = Double.valueOf(input.getText().toString()); mServingg.setText(df.format(values)); mServingSizeUpdated.setText(df.format(values)); mCalUpdate.setText(dfW.format(Double.valueOf(mCalories) * values)); mCalorieProgress = Double.valueOf(mCalories) * values; mFattieUpdate.setText(df.format(Double.valueOf(mFat) * values)); mFatProgress = Double.valueOf(mFat) * values; mSaturatedFatUpdate.setText(df.format(Double.valueOf(mSaturatedFat) * values)); mCholesterolUpdate.setText(df.format(Double.valueOf(mCholesterol) * values)); mSodiumUpdate.setText(df.format(Double.valueOf(mSodium) * values)); mCarbUpdate.setText(df.format(Double.valueOf(mCarbohydrates) * values)); mCarbProgress = Double.valueOf(mCarbohydrates) * values; mFiberUpdate.setText(df.format(Double.valueOf(mFiber) * values)); mSugarUpdate.setText(df.format(Double.valueOf(mSugar) * values)); mProUpdate.setText(df.format(Double.valueOf(mProtein) * values)); mProteinProgress = Double.valueOf(mProtein) * values; mVitAUpdate.setText(df.format(Double.valueOf(mVitA) * values)); mVitCUpdate.setText(df.format(Double.valueOf(mVitC) * values)); mCalciumUpdate.setText(df.format(Double.valueOf(mCalcium) * values)); mIronUpdate.setText(df.format(Double.valueOf(mIron) * values)); progressBars(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setCancelable(false); alert.show(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); } }); }
From source file:com.novemser.voicetest.ui.MainActivity.java
public void sendMessage(View view) { msg = mMsg.getText().toString();//from w w w . j av a 2 s . co m if (TextUtils.isEmpty(msg)) { Toast.makeText(this, getResources().getText(R.string.noTextWarning), Toast.LENGTH_LONG).show(); return; } ChatMessage to = new ChatMessage(ChatMessage.Type.OUTPUT, msg); to.setDate(new Date()); mDatas.add(to); mAdapter.notifyDataSetChanged(); mChatView.setSelection(mDatas.size() - 1); mMsg.setText(""); // InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // InputMethodManager if (imm.isActive()) { // ? imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); // ????? } understander.understandText(msg, textUnderstanderListener); }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
private void saveSource() { final Intent sourceIntent = new Intent(); String title = sourceTitle.getText().toString(); String data = sourceData.getText().toString(); if (type.equals(AppSettings.FOLDER)) { data = folderData;/*from www. j av a 2 s. co m*/ } if (title.equals("")) { Toast.makeText(appContext, "Title cannot be empty", Toast.LENGTH_SHORT).show(); return; } if (data.equals("")) { Toast.makeText(appContext, "Data cannot be empty", Toast.LENGTH_SHORT).show(); return; } int num = 0; try { num = Integer.parseInt(sourceNum.getText().toString()); } catch (NumberFormatException e) { num = 1; } switch (type) { case AppSettings.WEBSITE: if (!data.contains("http")) { data = "http://" + data; } break; } if (sourcePosition == -1) { if (FileHandler.isDownloading) { Toast.makeText(appContext, "Cannot add source while downloading", Toast.LENGTH_SHORT).show(); return; } sourceIntent.setAction(SourceListFragment.ADD_ENTRY); } else { if (!getArguments().getString("title").equals(title)) { FileHandler.renameFolder(getArguments().getString("title"), title); } if (FileHandler.isDownloading) { Toast.makeText(appContext, "Cannot edit while downloading", Toast.LENGTH_SHORT).show(); return; } sourceIntent.setAction(SourceListFragment.SET_ENTRY); } sourceIntent.putExtra("type", type); sourceIntent.putExtra("title", sourceTitle.getText().toString()); sourceIntent.putExtra("data", data); sourceIntent.putExtra("num", num); sourceIntent.putExtra("position", sourcePosition); sourceIntent.putExtra("use", sourceUse.isChecked()); sourceIntent.putExtra("preview", ((CustomSwitchPreference) findPreference("source_show_preview")).isChecked()); sourceIntent.putExtra("use_time", timePref.isChecked()); sourceIntent.putExtra("time", String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)); try { InputMethodManager im = (InputMethodManager) appContext.getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { e.printStackTrace(); } final int screenHeight = getResources().getDisplayMetrics().heightPixels; final View fragmentView = getView(); if (fragmentView != null) { final float viewStartY = getView().getY(); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { fragmentView.setY((screenHeight - viewStartY) * interpolatedTime + viewStartY); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent); getFragmentManager().popBackStack(); } @Override public void onAnimationRepeat(Animation animation) { } }); animation.setDuration(SLIDE_EXIT_TIME); getView().startAnimation(animation); } else { LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent); } }
From source file:com.duy.pascal.ui.editor.BaseEditorActivity.java
protected void closeKeyBoard() { // Central system API to the overall input method framework (IMF) architecture InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = getCurrentFocus(); if (currentFocus != null) { // Base interface for a remotable object IBinder windowToken = currentFocus.getWindowToken(); // Hide type int hideType = InputMethodManager.HIDE_NOT_ALWAYS; // Hide the KeyBoard if (inputManager != null) { inputManager.hideSoftInputFromWindow(windowToken, hideType); }// www . j a v a2 s.com } }
From source file:info.mayuragarkar.calculator.MainActivity.java
/** minimize the on sceen keyboard */ private void minKeybrd() { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }