Example usage for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY

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

Introduction

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

Prototype

int HIDE_IMPLICIT_ONLY

To view the source code for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestHideSelf(int) to indicate that the soft input window should only be hidden if it was not explicitly shown by the user.

Usage

From source file:eu.trentorise.smartcampus.jp.MyItinerariesFragment.java

@Override
public void onStart() {
    super.onStart();
    TextView noitems = (TextView) getView().findViewById(R.id.myitinearies_noitems_label);
    //      if ((myItineraries==null)||(myItineraries.size()==0))
    //         {/* w ww . java2 s .  c om*/
    //         //put "empty string"
    //         noitems.setVisibility(View.VISIBLE);
    //         }
    //      else {
    noitems.setVisibility(View.GONE);
    //      }
    ListView myJourneysList = (ListView) getView().findViewById(R.id.myitineraries_list);
    adapter = new MyItinerariesListAdapter(getSherlockActivity(), R.layout.itinerarychoicessaved_row,
            myItineraries);
    myJourneysList.setAdapter(adapter);
    myJourneysList.setDivider(null);
    myJourneysList.setDividerHeight(Utils.convertDpToPixel(6, getActivity()));

    SCAsyncTask<Void, Void, List<BasicItinerary>> task = new SCAsyncTask<Void, Void, List<BasicItinerary>>(
            getSherlockActivity(), new GetMyItinerariesProcessor(getSherlockActivity(), adapter));
    task.execute();

    myJourneysList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager()
                    .beginTransaction();
            Fragment fragment = MyItineraryFragment.newInstance(adapter.getItem(position));
            fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            fragmentTransaction.replace(Config.mainlayout, fragment, Config.MY_JOURNEYS_FRAGMENT_TAG);
            fragmentTransaction.addToBackStack(fragment.getTag());
            fragmentTransaction.commit();
        }
    });
    //hide keyboard if it is still open
    InputMethodManager imm = (InputMethodManager) getSherlockActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getSherlockActivity().getWindow().getDecorView()
            .findViewById(android.R.id.content).getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:com.shopgun.android.utils.KeyboardUtils.java

/**
 * Request to show/hide the soft input window from the context of the window that is currently accepting input.
 *
 * @param context     A context/*from   ww  w  .  j  a v  a  2 s. c  om*/
 * @param windowToken A window token (IBinder)
 * @param visible     True to show input window, false to hide
 */
public static void setKeyboardVisible(Context context, IBinder windowToken, boolean visible) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (visible) {
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    } else if (windowToken != null) {
        imm.hideSoftInputFromWindow(windowToken, 0);
    }
}

From source file:luxsyp.corona.com.base.ui.activity.HomeActivity.java

private void initSearchButton() {
    search_fab.setClickable(true);/*  w  w w .  ja  v a 2s  . com*/
    search_fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            search_fab.setClickable(true);
            search_fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    try {
                        new MaterialDialog.Builder(HomeActivity.this).title(R.string.movie_name_search)
                                .content(R.string.movie_name_search)
                                .inputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME
                                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)
                                .input(R.string.movie_name_search, R.string.no_prefill,
                                        new MaterialDialog.InputCallback() {
                                            @Override
                                            public void onInput(MaterialDialog dialog, CharSequence input) {
                                                homeFragment.doSearch(input.toString());
                                                InputMethodManager imm = (InputMethodManager) getSystemService(
                                                        Context.INPUT_METHOD_SERVICE);
                                                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
                                            }
                                        })
                                .show();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    });
}

From source file:org.solovyev.android.messenger.ListViewFilter.java

public void toggleView() {
    final View view = fragment.getView();
    final FragmentActivity activity = fragment.getActivity();

    if (view != null && activity != null && filterEditText != null) {
        final ViewGroup filterBox = (ViewGroup) view.findViewById(R.id.mpp_list_filter);
        if (filterBox != null) {
            int visibility = filterBox.getVisibility();

            final InputMethodManager manager = (InputMethodManager) activity
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            if (visibility != View.VISIBLE) {
                filterBox.setVisibility(View.VISIBLE);
                filterEditText.requestFocus();

                manager.showSoftInput(filterEditText, InputMethodManager.SHOW_IMPLICIT);

            } else if (visibility != View.GONE) {
                // if filter box is visible before hiding it clear filter query
                filterEditText.getText().clear();
                filterEditText.clearFocus();

                manager.hideSoftInputFromWindow(filterEditText.getWindowToken(),
                        InputMethodManager.HIDE_IMPLICIT_ONLY);

                filterBox.setVisibility(View.GONE);
            }/*from www .  jav  a2s  .c  o  m*/
        }
    } else {
        Log.e(TAG, "toggleView() is called when view or activity is detached from fragment!");
    }
}

From source file:com.mifos.mifosxdroid.online.ClientSearchFragment.java

public void hideKeyboard() {

    inputMethodManager.hideSoftInputFromWindow(et_searchById.getWindowToken(),
            InputMethodManager.HIDE_IMPLICIT_ONLY);

}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

@Override
public void onProgressUpdate(@NonNull AbstractSearchTask task, GenericFile... files) {
    mAdapter.addFiles(files);//w w  w . j ava 2s  . c o m
    mInputMethodManager.hideSoftInputFromWindow(mInput.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:calibrationapp.spectoccular.com.keyboardtolinux.MainActivity.java

private void showSoftInput() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:edu.missouri.bas.activities.AdminManageActivity.java

private Dialog AdminPinDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(this);
    final View textEntryView = inflater.inflate(R.layout.pin_login, null);
    alert_text = (TextView) textEntryView.findViewById(R.id.pin_text);
    alert_text.setText("Please input PIN for administrator");
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*from w w  w  .j  av a 2s . c om*/
    builder.setTitle("Verify Admin PIN");
    builder.setView(textEntryView);
    //builder.setMessage("Please input PIN for administrator");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            //check networking

            adminPin = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String AdPin = adminPin.getText().toString();
            Log.d(TAG, "get from edittext is " + AdPin);

            HttpPost request = new HttpPost(
                    "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php");

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            //file_name 
            params.add(new BasicNameValuePair("userID", "0000"));
            //function
            params.add(new BasicNameValuePair("pre", "1"));
            //data                       
            params.add(new BasicNameValuePair("password", AdPin));

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                        //setResult(8);
                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Admin PIN is wrong, exit! Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        //setResult(9);
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Verify failed. Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        finish();
                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast toast = Toast.makeText(getApplicationContext(),
                        "Failed. Please try again, with network connection.", Toast.LENGTH_SHORT);
                toast.show();
                //set return code
                /*                        if(shp.getString(ASID, "").equals("")){
                   setResult(9);
                }else{
                   setResult(Activity.RESULT_CANCELED);
                }*/

                finish();
                e.printStackTrace();
            }

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            //set return code
            /*                    if(shp.getString(ASID, "").equals("")){
               setResult(9);
            }else{
               setResult(Activity.RESULT_CANCELED);
            }*/
            setResult(9);
            finish();
        }
    });
    return builder.create();
}

From source file:com.king.base.BaseDialogFragment.java

/**
 * ??//from ww w .  ja  v a2 s . c  o  m
 *
 * @param v
 */
public void hideInputMethod(final EditText v) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);

}