Example usage for android.content Context INPUT_METHOD_SERVICE

List of usage examples for android.content Context INPUT_METHOD_SERVICE

Introduction

In this page you can find the example usage for android.content Context INPUT_METHOD_SERVICE.

Prototype

String INPUT_METHOD_SERVICE

To view the source code for android.content Context INPUT_METHOD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.inputmethod.InputMethodManager for accessing input methods.

Usage

From source file:com.wenwen.chatuidemo.activity.ContactSickFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    contactList = new ArrayList<MyUser1>();
    // ?contactlist
    getContactList();//from w  ww  .  j  a v  a2  s. com
    // adapter
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), SickInfo.class).putExtra("uid",
                    contactList.get(position).getAccount_id()));
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

}

From source file:com.wenwen.chatuidemo.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    DebugLog.i(TAG, "onActivityCreated");
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    contactList = new ArrayList<MyUser>();
    // ?contactlist
    getContactList();/*from   w w  w  .  j  a va2 s  .c  o m*/
    // adapter
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), ColleaguesInfo.class).putExtra("uid",
                    contactList.get(position).getAccount_id()));
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //startActivity(new Intent(getActivity(), AddContactActivity.class));
            startActivityForResult(new Intent(getActivity(), AddContactActivity.class),
                    Constants.ActionCode.ACT_FIND);
        }
    });
}

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();// ww  w  . ja v a 2s.  com

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    } else {
        query = intent.getStringExtra(Constants.EXTRA_QUERY_TERM);
        Log.d(TAG, "Query from other intent: " + query);
    }

    // After setting up variables so that they can be accessed in getApiUrl
    // which is called at the end of super.onCreate
    super.onCreate(savedInstanceState);

    // Push the search box into the layout group below the logo bar and above
    // the 'search results' title bar
    ViewGroup container = (ViewGroup) findViewById(R.id.TitleGroup);
    container.addView(ViewGroup.inflate(this, R.layout.partial_search_box, null), 0);
    searchBox = (EditText) findViewById(R.id.SearchText);
    searchBox.setText(query);
    searchBox.setOnKeyListener(this);
    ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button);
    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Click", "Search", 0);
            search();
        }
    });

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:com.springsource.greenhouse.twitter.PostTweetActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.post_tweet);

    textViewCount = (TextView) this.findViewById(R.id.post_tweet_count);
    textWatcher = new TextWatcher() {
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }/*from   w  ww  .  j  a v  a2  s.c o  m*/

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            textViewCount.setText(String.valueOf(MAX_TWEET_LENGTH - s.length()));
        }

        public void afterTextChanged(Editable s) {
        }
    };

    final EditText editText = (EditText) findViewById(R.id.post_tweet_text);
    editText.addTextChangedListener(textWatcher);

    final Button button = (Button) findViewById(R.id.post_tweet_button);
    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.post_tweet_text);
            inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
            new PostTweetTask().execute();
        }
    });
}

From source file:com.elkriefy.android.apps.authenticationexample.fingerprintdialog.FingerprintModule.java

@Provides
public InputMethodManager providesInputMethodManager(Context context) {
    return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}

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) {
        }/*from www  .j  a  v  a2  s.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:com.lugia.timetable.LoginActivity.java

public void onClick(View v) {
    // not continue button? i really not sure what you have clicked.
    if (v.getId() != R.id.button_continue)
        return;/*from   w w  w. j  a  va2  s . co  m*/

    String mmuid = mMmuIdInput.getText().toString();
    String password = mPasswordInput.getText().toString();

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

    mProgressDialog = ProgressDialog.show(LoginActivity.this, "", "Please wait...", true, false);
    mProgressDialog.setCancelable(false);

    LoginThread thread = new LoginThread(mmuid, password);
    thread.start();
}

From source file:io.trigger.forge.android.modules.keyboard.API.java

private static InputMethodManager getKeyboard() {
    ForgeActivity activity = ForgeApp.getActivity();
    return (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:net.olejon.mdapp.NasjonaleRetningslinjerActivity.java

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

    // Input manager
    mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Layout/*  w  w  w .j  av  a  2  s.c om*/
    setContentView(R.layout.activity_nasjonale_retningslinjer);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.nasjonale_retningslinjer_toolbar);
    toolbar.setTitle(getString(R.string.nasjonale_retningslinjer_title));

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mToolbarSearchLayout = (LinearLayout) findViewById(R.id.nasjonale_retningslinjer_toolbar_search_layout);
    mToolbarSearchEditText = (EditText) findViewById(R.id.nasjonale_retningslinjer_toolbar_search);

    mToolbarSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_SEARCH || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0);

                search(mToolbarSearchEditText.getText().toString().trim());

                return true;
            }

            return false;
        }
    });

    ImageButton imageButton = (ImageButton) findViewById(R.id.nasjonale_retningslinjer_toolbar_clear_search);

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mToolbarSearchEditText.setText("");
        }
    });

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.nasjonale_retningslinjer_toolbar_progressbar);

    // Floating action button
    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.nasjonale_retningslinjer_fab);

    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mToolbarSearchLayout.getVisibility() == View.VISIBLE) {
                mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0);

                search(mToolbarSearchEditText.getText().toString().trim());
            } else {
                mToolbarSearchLayout.setVisibility(View.VISIBLE);
                mToolbarSearchEditText.requestFocus();

                mInputMethodManager.showSoftInput(mToolbarSearchEditText, 0);
            }
        }
    });

    // List
    mListView = (ListView) findViewById(R.id.nasjonale_retningslinjer_list);

    View listViewEmpty = findViewById(R.id.nasjonale_retningslinjer_list_empty);
    mListView.setEmptyView(listViewEmpty);

    View listViewHeader = getLayoutInflater().inflate(R.layout.activity_nasjonale_retningslinjer_list_subheader,
            mListView, false);
    mListView.addHeaderView(listViewHeader, null, false);
}

From source file:com.tilusnet.wayta.MainActivity2.java

private void launchClavin() {
    // Retrieve the city data from the web service
    // In a worker thread since it's a network operation.

    map.clear();/*ww w .java  2s  .c  o m*/
    markers.clear();

    // Hide soft keyboard
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

    Toast.makeText(getApplicationContext(), "Querying...", Toast.LENGTH_SHORT).show();
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                queryClavin();
            } catch (IOException e) {
                errMsg = "Cannot retrieve cities";
                Log.e(LOG_TAG, errMsg, e);
                //               Toast.makeText(instance, errMsg, Toast.LENGTH_SHORT).show();
                return;
            }
        }
    }).start();
}