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:library.artaris.cn.library.utils.SystemUtils.java
/** * //from w ww .ja va2s . c o m * @param context */ public static void showSoftInput(Context context) { InputMethodManager inputMethodManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java
/** * Sets the text of the comment being edited to the new text entered by the user, * sets the value of EditCommentFragment.oldText and EditCommentFragment.oldThumbnail * to null so that the state isn't preserved across comment edits, and returns the * user to their previous fragment./* ww w . j a v a 2 s . com*/ * * @param view The button that was pressed to call makeEdit. */ public void makeEdit(View view) { EditFragment.oldText = null; EditFragment.oldThumbnail = null; editComment.setTextPost(newTextPost.getText().toString()); ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setMessage("Posting to Server"); if (isThread) { String threadTitle = thread.getTitle(); thread.setBodyComment(editComment); ThreadManager.startPost(editComment, threadTitle, editComment.getLocation(), dialog, true); CacheManager.getInstance().serializeThreadList(ThreadList.getThreads()); } else { ThreadManager.startPost(editComment, null, editComment.getLocation(), dialog, true); } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); getFragmentManager().popBackStackImmediate(); }
From source file:com.seamusdawkins.autocomplete.MainActivity.java
/** * This method will hide the keyboard./*w ww. j a v a2s . c o m*/ */ private void hideKeyboard() { View view = getCurrentFocus(); if (view != null) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:de.msal.shoutemo.fragments.ChatFragment.java
private void hideKeyboard() { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); // check if no view has focus: View view = getActivity().getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w. ja v a 2 s . co m*/ }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * //from w ww . jav a2 s. c om * @param context */ public static void closeSoftInput(Context context) { InputMethodManager inputMethodManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && ((Activity) context).getCurrentFocus() != null) { inputMethodManager.hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.easemob.chatuidemo.activity.GroupPickContactsActivity.java
private void initContactList(final List<User> contacts) { query.setAdapter(/*from w w w . j a va2 s. c o m*/ new PickContactsAutoCompleteAdapter(mContext, contacts, departments, roles, new ArrayList<>())); query.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { isTargeted = true; Object object = adapterView.getAdapter().getItem(i); if (object instanceof Role) { Role role = (Role) object; contactAdapter.setFilter(role, PickContactsAdapter.TYPE_ROLE); query.setText(role.getName()); } else if (object instanceof Department) { Department department = (Department) object; contactAdapter.setFilter(department, PickContactsAdapter.TYPE_DEPARTMENT); query.setText(department.getName()); } else if (object instanceof User) { User user = (User) object; contactAdapter.setFilter(user, PickContactsAdapter.TYPE_USER); query.setText(user.getNick()); } } }); query.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { handler.removeCallbacks(searchRunnable); if (!isTargeted) { if (editable.length() == 0) { contactAdapter.setFilter(null, PickContactsAdapter.TYPE_ALL); } else { clearSearch.setVisibility(View.VISIBLE); handler.postDelayed(searchRunnable, 1000); } } isTargeted = false; selectedFilterCheckBox.setChecked(false); } }); // list? Collections.sort(contacts, new Comparator<User>() { @Override public int compare(User lhs, User rhs) { int headerResult = lhs.getHeader().compareTo(rhs.getHeader()); if (headerResult == 0) { // ??nick return (lhs.getNick().compareTo(rhs.getNick())); } else { return headerResult; } } }); contactAdapter = new PickContactsAdapter(this, contacts, exitingMembers); listView.setAdapter(contactAdapter); listView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { InputMethodManager imm = (InputMethodManager) mContext .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(query.getWindowToken(), 0); return false; } }); contactAdapter.setOnSelectedCountChangeListener(new PickContactsAdapter.OnSelectedCountChangeListener() { @Override public void onSelectedCountChange(int count) { setSelectedNumber(count); setAllSelectedStatus(contactAdapter.getAllSelectedStatus()); } }); contactAdapter.setOnDataSetChangedListener(new PickContactsAdapter.OnDataSetChangedListener() { @Override public void onDataSetChanged() { if (contactAdapter.getCount() > 0) { findViewById(R.id.none_result_view).setVisibility(View.GONE); } else { if (selectedFilterCheckBox.isChecked()) { } else { findViewById(R.id.none_result_view).setVisibility(View.VISIBLE); } } } }); // ?? InputMethodManager inputMethodManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); if (mActivity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (mActivity.getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.eugene.fithealthmaingit.UI.ManualEntrySaveMealFragment.java
private void updateItems() { mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//www . jav a 2 s . c o m public void onClick(View v) { Intent intent = new Intent(getActivity(), ChooseAddMealActivity.class); intent.putExtra(Globals.MEAL_TYPE, mealType); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mToolbar.inflateMenu(R.menu.menu_user_info); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_save) saveMeal(); return false; } }); mServingSizeUpdated.setText("1"); LinearLayout changeServing = (LinearLayout) v.findViewById(R.id.changeServing); changeServing.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Update Serving Size: "); alert.setMessage("Servings Consumed"); final EditText input = new EditText(getActivity()); 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) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setCancelable(false); alert.show(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); } }); }
From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java
private void hideKeyboard() { View view = getCurrentFocus(); if (view != null) { inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/* w w w . j av a 2 s . co m*/ }
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 . jav a 2 s . c o m if (v != null) { inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:it.chefacile.app.MainActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = this; chefacileDb = new DatabaseHelper(this); // FilterButton = (ImageButton) findViewById(R.id.buttonfilter); TutorialButton = (ImageButton) findViewById(R.id.button); // AddButton = (ImageButton) findViewById(R.id.button2); responseView = (TextView) findViewById(R.id.responseView); editText = (EditText) findViewById(R.id.ingredientText); progressBar = (ProgressBar) findViewById(R.id.progressBar); //Show = (ImageButton) findViewById(R.id.buttonShow); //Show2 = (ImageButton) findViewById(R.id.buttonShow2); materialAnimatedSwitch = (MaterialAnimatedSwitch) findViewById(R.id.pin); //buttoncuisine = (ImageButton) findViewById(R.id.btn_cuisine); //buttondiet = (ImageButton) findViewById(R.id.btn_diet); //buttonintol = (ImageButton) findViewById(R.id.btn_intoll); //Mostra = (Button) findViewById(R.id.btn_mostra); final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible animation.setDuration(1000); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(5); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); ImageView icon = new ImageView(this); // Create an icon icon.setImageDrawable(getResources().getDrawable(R.drawable.logo)); final com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton actionButton = new com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.Builder( this).setPosition( com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.POSITION_RIGHT_CENTER) .setContentView(icon).build(); SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this); // repeat many times: ImageView dietIcon = new ImageView(this); dietIcon.setImageDrawable(getResources().getDrawable(R.drawable.diet)); SubActionButton button1 = itemBuilder.setContentView(dietIcon).build(); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showSingleChoiceDialogDiet(v); }/*from w ww . ja va2s . c om*/ }); ImageView intolIcon = new ImageView(this); intolIcon.setImageDrawable(getResources().getDrawable(R.drawable.intoll)); SubActionButton button2 = itemBuilder.setContentView(intolIcon).build(); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showMultiChoiceDialogIntol(v); } }); ImageView cuisineIcon = new ImageView(this); cuisineIcon.setImageDrawable(getResources().getDrawable(R.drawable.cook12)); SubActionButton button3 = itemBuilder.setContentView(cuisineIcon).build(); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showMultiChoiceDialogCuisine(v); } }); ImageView favouriteIcon = new ImageView(this); favouriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.favorite)); SubActionButton button4 = itemBuilder.setContentView(favouriteIcon).build(); button4.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showSimpleListDialogFav(v); } }); ImageView wandIcon = new ImageView(this); wandIcon.setImageDrawable(getResources().getDrawable(R.drawable.wand)); SubActionButton button5 = itemBuilder.setContentView(wandIcon).build(); button5.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { sugg = getSuggestion(); suggOccurrences = getCount(); showSimpleListDialogSuggestions(v); } }); final FloatingActionButton actionABC = (FloatingActionButton) findViewById(R.id.action_abc); actionABC.bringToFront(); actionABC.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (ingredients.length() < 2) { Snackbar.make(responseView, "Insert at least one ingredient", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } else { new RetrieveFeedTask().execute(); } } // Snackbar.make(view, "Non disponibile, mangia l'aria", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); }); FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this).setStartAngle(90).setEndAngle(270) .addSubActionView(button1).addSubActionView(button2).addSubActionView(button3) .addSubActionView(button4).addSubActionView(button5).attachTo(actionButton).build(); startDatabase(chefacileDb); for (int j = 0; j < cuisineItems.length; j++) { cuisineItems[j] = cuisineItems[j].substring(0, 1).toUpperCase() + cuisineItems[j].substring(1); } Arrays.sort(cuisineItems); for (int i = 0; i < 24; i++) { cuisineBool[i] = false; } Arrays.sort(intolItems); for (int i = 0; i < 11; i++) { intolBool[i] = false; } mListView = (MaterialListView) findViewById(R.id.material_listview); adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); TutorialButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, IntroScreenActivity.class)); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }); iv = (ImageView) findViewById(R.id.imageView); iv.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { clicks++; Log.d("CLICKS", String.valueOf(clicks)); if (clicks == 15) { Log.d("IMAGE SHOWN", "mai vero"); setBackground(iv); } } }); materialAnimatedSwitch.setOnCheckedChangeListener(new MaterialAnimatedSwitch.OnCheckedChangeListener() { @Override public void onCheckedChanged(boolean isChecked) { if (isChecked == true) { ranking = 2; Toast.makeText(getApplicationContext(), "Minimize missing ingredients", Toast.LENGTH_SHORT) .show(); } else { ranking = 1; Toast.makeText(getApplicationContext(), "Maximize used ingredients", Toast.LENGTH_SHORT).show(); } Log.d("Ranking", String.valueOf(ranking)); } }); final CharSequence[] items = { "Maximize used ingredients", "Minimize missing ingredients" }; editText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (!(editText.getText().toString().trim().equals(""))) { String input; String s1 = editText.getText().toString().substring(0, 1).toUpperCase(); String s2 = editText.getText().toString().substring(1); input = s1 + s2; Log.d("INPUT: ", input); searchedIngredients.add(input); Log.d("SEARCHED INGR LIST", searchedIngredients.toString()); if (!chefacileDb.findIngredientPREF(input)) { if (chefacileDb.findIngredient(input)) { chefacileDb.updateCount(input); mapIngredients = chefacileDb.getDataInMapIngredient(); Map<String, Integer> map2; map2 = sortByValue(mapIngredients); Log.d("MAPPACOUNT: ", map2.toString()); } else { if (chefacileDb.occursExceeded()) { //chefacileDb.deleteMinimum(input); // chefacileDb.insertDataIngredient(input); mapIngredients = chefacileDb.getDataInMapIngredient(); Map<String, Integer> map3; map3 = sortByValue(mapIngredients); Log.d("MAPPAINGREDIENTE: ", map3.toString()); } else { chefacileDb.insertDataIngredient(input); mapIngredients = chefacileDb.getDataInMapIngredient(); Map<String, Integer> map3; map3 = sortByValue(mapIngredients); Log.d("MAPPAINGREDIENTE: ", map3.toString()); } } } } if (editText.getText().toString().trim().equals("")) { ingredients += editText.getText().toString().trim() + ""; editText.getText().clear(); } else { ingredients += editText.getText().toString().replaceAll(" ", "+").trim().toLowerCase() + ","; singleIngredient = editText.getText().toString().trim().toLowerCase(); currentIngredient = singleIngredient; new RetrieveIngredientTask().execute(); //adapter.add(singleIngredient.substring(0,1).toUpperCase() + singleIngredient.substring(1)); } InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(editText.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); actionABC.startAnimation(animation); return true; default: break; } } return false; } }); responseView = (TextView) findViewById(R.id.responseView); editText = (EditText) findViewById(R.id.ingredientText); progressBar = (ProgressBar) findViewById(R.id.progressBar); }