Skip to content

Instantly share code, notes, and snippets.

@shihabmi7
Created August 4, 2016 01:06
Show Gist options
  • Save shihabmi7/777bb978765d5e5de0f076947058b969 to your computer and use it in GitHub Desktop.
Save shihabmi7/777bb978765d5e5de0f076947058b969 to your computer and use it in GitHub Desktop.
Edittext Ime , Hide keyboard
EditText
android:id="@+id/et_go"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:inputType="text"
android:imeOptions="actionGo"
android:hint="@string/hnt_et_go" />
et_go.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_GO){
// Creating uri to be opened
Uri uri = Uri.parse("http://"+etColor.getText().toString());
// Creating an intent to open the uri
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// Opening the uri in an activity
startActivity(intent);
}
return false;
}
});
// Hide the soft keyboard
The following code snippet will help you to hide or dismiss the soft keyboard from the screen and take the input focus out form the editable view.
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment