List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:com.amberfog.countryflagsdemo.BaseFlagFragment.java
protected void hideKeyboard(View v) { InputMethodManager imm = (InputMethodManager) v.getContext().getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:com.app.sample.chatting.widget.KJChatKeyboard.java
/** * ??//from w ww . ja v a 2s. c om */ public void hideKeyboard(Context context) { Activity activity = (Activity) context; if (activity != null) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive() && activity.getCurrentFocus() != null) { imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); } } }
From source file:com.springsource.greenhouse.events.sessions.EventSessionRatingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.event_session_rating); textViewCount = (TextView) this.findViewById(R.id.event_session_rating_count); textWatcher = new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int count, int after) { }/* www . j av a 2s .c o m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { textViewCount.setText(String.valueOf(MAX_LENGTH - s.length())); } public void afterTextChanged(Editable s) { } }; final EditText editText = (EditText) findViewById(R.id.event_session_rating_text); editText.addTextChangedListener(textWatcher); final Button submitButton = (Button) findViewById(R.id.event_session_rating_submit); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // hide the soft keypad InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); EditText editText = (EditText) findViewById(R.id.event_session_rating_text); inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); submitRating(); } }); final Button selectStartButton = (Button) findViewById(R.id.event_session_rating_select_star); selectStartButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showSelectStarRatingDialog(); } }); }
From source file:ca.shoaib.ping.PingListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_ping_list, container, false); mListView = (ListView) rootView.findViewById(R.id.list_ping); pingListAdapter = new PingListAdapter(getActivity(), R.layout.ping_row, pingList); mListView.setAdapter(pingListAdapter); //mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . ja v a 2s .c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mPingListCallback.onPingSelected(pingList.get(position)); mActivatedPosition = position; setActivatedPosition(position); //Log.d(TAG, "ArtistId: " + artistList.get(position).getArtistId()); } }); pb = (ProgressBar) rootView.findViewById(R.id.progress_bar); et = (EditText) rootView.findViewById(R.id.ping_destination); tv = (TextView) rootView.findViewById(R.id.ping_result); btn = (Button) rootView.findViewById(R.id.ping_start); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String stringUrl = et.getText().toString(); ConnectivityManager connMgr = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { AsyncTask pingTask = new PingTask(getActivity(), pingList, pingListAdapter).execute(stringUrl); } else { tv.setTextSize(20); tv.setTextColor(Color.RED); tv.setText(R.string.no_internet); } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); } }); et.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_LEFT = 0; final int DRAWABLE_TOP = 1; final int DRAWABLE_RIGHT = 2; final int DRAWABLE_BOTTOM = 3; if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getRawX() >= (et.getRight() - et.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { et.setText(""); et.selectAll(); return true; } } return false; } }); return rootView; }
From source file:com.emobc.android.activities.generators.FormActivityGenerator.java
private EditText insertTextField(final Activity activity, FormDataItem dataItem) { EditText txt = new EditText(activity); txt.setTag(dataItem.getFieldName()); txt.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override/*from ww w . jav a2 s. com*/ public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } } }); return txt; }
From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java
private void closeKeyboard() { InputMethodManager imm = (InputMethodManager) mParentActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mInputEditText.getWindowToken(), 0); Log.d("Cocos2dxEditBox", "closeKeyboard"); }
From source file:com.og.tracerouteping.ui.TraceActivity.java
/** * Hides the keyboard//from w w w . j ava 2 s . co m * * @param currentEditText * The current selected edittext */ public void hideSoftwareKeyboard(EditText currentEditText) { InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive()) { imm.hideSoftInputFromWindow(currentEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.tdispatch.passenger.fragment.SearchAddressFragment.java
protected void hideSoftKeyboard() { View v = mFragmentView.findViewById(R.id.address); InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:com.scigames.slidegame.Registration1UserNameActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { View v = getCurrentFocus();/* w w w .j a v a 2 s .c o m*/ boolean ret = super.dispatchTouchEvent(event); if (v instanceof EditText) { View w = getCurrentFocus(); int scrcoords[] = new int[2]; w.getLocationOnScreen(scrcoords); float x = event.getRawX() + w.getLeft() - scrcoords[0]; float y = event.getRawY() + w.getTop() - scrcoords[1]; Log.d("Activity", "Touch event " + event.getRawX() + "," + event.getRawY() + " " + x + "," + y + " rect " + w.getLeft() + "," + w.getTop() + "," + w.getRight() + "," + w.getBottom() + " coords " + scrcoords[0] + "," + scrcoords[1]); if (event.getAction() == MotionEvent.ACTION_UP && (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w.getBottom())) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); } } return ret; }
From source file:com.google.maps.android.utils.demo.HeatmapsPlacesDemoActivity.java
/** * Takes the input from the user and generates the required heatmap. * Called when a search query is submitted *//* w ww .j a v a2 s . c o m*/ public void submit() { if ("YOUR_KEY_HERE".equals(API_KEY)) { Toast.makeText(this, "Please sign up for a Places API key and add it to HeatmapsPlacesDemoActivity.API_KEY", Toast.LENGTH_LONG).show(); return; } EditText editText = (EditText) findViewById(R.id.input_text); String keyword = editText.getText().toString(); if (mOverlays.contains(keyword)) { Toast.makeText(this, "This keyword has already been inputted :(", Toast.LENGTH_SHORT).show(); } else if (mOverlaysRendered == MAX_CHECKBOXES) { Toast.makeText(this, "You can only input " + MAX_CHECKBOXES + " keywords. :(", Toast.LENGTH_SHORT) .show(); } else if (keyword.length() != 0) { mOverlaysInput++; ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar); progressBar.setVisibility(View.VISIBLE); new MakeOverlayTask().execute(keyword); editText.setText(""); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } }