Example usage for android.view.inputmethod InputMethodManager hideSoftInputFromWindow

List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager hideSoftInputFromWindow.

Prototype

public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) 

Source Link

Document

Synonym for #hideSoftInputFromWindow(IBinder,int,ResultReceiver) without a result: request to hide the soft input window from the context of the window that is currently accepting input.

Usage

From source file:org.kepennar.android.client.social.twitter.TwitterDirectMessageActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.twitter_direct_message_activity_layout);

    _twitterApi = getApplicationContext().getConnectionRepository().findPrimaryConnectionToApi(TwitterApi.class)
            .getApi();//  w  w w  . j  av  a 2  s .com

    // Initiate the POST request when the button is clicked
    final Button button = (Button) findViewById(R.id.button_tweet);
    button.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.edit_text_message);
            inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);

            new PostDirectMessageTask().execute();
        }
    });
}

From source file:com.anykey.balala.activity.BaseActivity.java

protected void hideSoftInputView() {
    if (getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }/*w  w  w .  j  a  v  a 2  s . c o  m*/
}

From source file:edu.rit.csh.androidwebnews.DisplayThreadsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getSupportMenuInflater().inflate(R.menu.displaythreads_menu, menu);
    // Get the SearchView and set the searchable configuration
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            return true;
        }//  ww w . j  a va  2  s  .  c o  m

        public boolean onQueryTextSubmit(String query) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
            Intent intent = new Intent(DisplayThreadsActivity.this, SearchResultsActivity.class);
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("keywords", query);
            intent.putExtra("params", params);
            startActivity(intent);
            return true;
        }
    };
    searchView.setOnQueryTextListener(queryTextListener);
    return super.onCreateOptionsMenu(menu);
}

From source file:edu.rit.csh.androidwebnews.PostSwipeableActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getSupportMenuInflater().inflate(R.menu.postswipable_menu, menu);
    // Get the SearchView and set the searchable configuration
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            return true;
        }// ww  w .  j  a  va  2 s .com

        public boolean onQueryTextSubmit(String query) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
            Intent intent = new Intent(PostSwipeableActivity.this, SearchResultsActivity.class);
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("keywords", query);
            intent.putExtra("params", params);
            startActivity(intent);
            return true;
        }
    };
    searchView.setOnQueryTextListener(queryTextListener);
    return super.onCreateOptionsMenu(menu);
}

From source file:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java

public void hideKeyboard() {
    InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mTextEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:ca.rmen.android.poetassistant.main.dictionaries.ResultListFragment.java

@Override
public void onLoadFinished(Loader<ResultListData<T>> loader, ResultListData<T> data) {
    Log.d(TAG, mTab + ": onLoadFinished() called with: " + "loader = [" + loader + "], data = [" + data + "]");
    mAdapter.clear();/* w w w.j a va2  s.co m*/
    //noinspection unchecked
    mAdapter.addAll(data.data);
    mData = data;
    updateUi();

    // Hide the keyboard
    mBinding.recyclerView.requestFocus();
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mBinding.recyclerView.getWindowToken(), 0);
}

From source file:cn.count.easydrive366.DriverLicenseEditActivity.java

private void save() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(((EditText) findViewById(R.id.edt_driverlicense_name)).getWindowToken(), 0);
    if (!this.isOnline()) {
        this.showMessage(this.getResources().getString(R.string.no_network), null);
        return;/*from w  w w. jav  a  2s .  c o  m*/
    }
    String name = ((EditText) findViewById(R.id.edt_driverlicense_name)).getText().toString().trim();
    String id = ((EditText) findViewById(R.id.edt_driverlicense_number)).getText().toString().trim()
            .toUpperCase();
    if (name.equals("")) {
        this.showMessage(this.getResources().getString(R.string.name_is_empty), null);
        return;
    }
    if (id.equals("") || id.length() != 18 || !personIdValidation(id)) {
        this.showMessage(this.getResources().getString(R.string.id_is_wrong), null);
        return;
    }
    String url = String.format("api/add_driver_license?user_id=%d&name=%s&license_id=%s&type=%s&init_date=%s",
            AppSettings.userid,
            ((EditText) findViewById(R.id.edt_driverlicense_name)).getText().toString().toUpperCase(),
            ((EditText) findViewById(R.id.edt_driverlicense_number)).getText().toString().toUpperCase(),
            ((TextView) findViewById(R.id.edt_driverlicense_car_type)).getText(),
            ((TextView) findViewById(R.id.edt_driverlicense_init_date)).getText());
    this.get(url, 2, this.getResources().getString(R.string.app_uploading));
}

From source file:com.bjerva.tsplex.fragments.PagerFragment.java

public void onPause() {
    if (search != null) {
        InputMethodManager imm = (InputMethodManager) ma.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
    }//from w  ww . ja  v  a2s  . c om
    previousFrag = mPager.getCurrentItem();
    super.onPause();
}

From source file:com.firesoft.member.Activity.C1_PublishOrderActivity.java

private void CloseKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(member_no.getWindowToken(), 0);
}

From source file:com.easemob.helpdeskdemo.ui.SatisfactionActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

    // Edittext /*from w  w  w  .  j  a  va2 s .c o  m*/
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if (isShouldHideInput(v, ev)) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            if (inputManager != null) {
                inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }

        return super.dispatchTouchEvent(ev);
    }
    // ????TouchEvent
    if (getWindow().superDispatchTouchEvent(ev)) {
        return true;
    }
    return onTouchEvent(ev);
}