List of usage examples for android.view.inputmethod InputMethodManager showSoftInput
public boolean showSoftInput(View view, int flags)
From source file:hobby.wei.c.framework.AbsActivity.java
protected void showInputMethod() { View focusView = getCurrentFocus(); if (focusView != null) { //? InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(focusView, InputMethodManager.SHOW_IMPLICIT); }//from ww w . j a v a 2 s . c om }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment.java
/** * Creates dialog/*from w ww. ja v a 2 s . c om*/ */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); mMessenger = getArguments().getParcelable(ARG_MESSENGER); String predefinedName = getArguments().getString(ARG_NAME); CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(R.string.edit_key_action_add_identity); LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.add_user_id_dialog, null); alert.setView(view); mName = (NameEditText) view.findViewById(R.id.add_user_id_name); mEmail = (EmailEditText) view.findViewById(R.id.add_user_id_address); mName.setText(predefinedName); alert.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dismiss(); // return new user id back to activity Bundle data = new Bundle(); String userId = KeyRing.createUserId( new OpenPgpUtils.UserId(mName.getText().toString(), mEmail.getText().toString(), null)); data.putString(MESSAGE_DATA_USER_ID, userId); sendMessageToHandler(MESSAGE_OKAY, data); } }); alert.setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // Hack to open keyboard. // This is the only method that I found to work across all Android versions // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/ // Notes: * onCreateView can't be used because we want to add buttons to the dialog // * opening in onActivityCreated does not work on Android 4.4 mEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mEmail.post(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEmail, InputMethodManager.SHOW_IMPLICIT); } }); } }); mEmail.requestFocus(); return alert.show(); }
From source file:net.gsantner.opoc.util.ActivityUtils.java
public void showSoftKeyboard() { InputMethodManager imm = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); if (imm != null && _activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { imm.showSoftInput(_activity.getCurrentFocus(), InputMethodManager.SHOW_FORCED); }//from w ww . j av a2 s.c o m }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddEmailDialogFragment.java
/** * Creates dialog//from w ww.j a v a2s.co m */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); mMessenger = getArguments().getParcelable(ARG_MESSENGER); CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); alert.setTitle(R.string.create_key_add_email); LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.add_email_dialog, null); alert.setView(view); mEmail = (EmailEditText) view.findViewById(R.id.add_email_address); alert.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dismiss(); // return new user id back to activity Bundle data = new Bundle(); String email = mEmail.getText().toString(); data.putString(MESSAGE_DATA_EMAIL, email); sendMessageToHandler(MESSAGE_OKAY, data); } }); alert.setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // Hack to open keyboard. // This is the only method that I found to work across all Android versions // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/ // Notes: * onCreateView can't be used because we want to add buttons to the dialog // * opening in onActivityCreated does not work on Android 4.4 mEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mEmail.post(new Runnable() { @Override public void run() { if (getActivity() != null) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEmail, InputMethodManager.SHOW_IMPLICIT); } } }); } }); mEmail.requestFocus(); mEmail.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE); mEmail.setOnEditorActionListener(this); return alert.show(); }
From source file:org.akvo.rsr.up.ProjectListActivity.java
private void showSoftKeyBoard(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.showSoftInput(v, 0); }
From source file:org.badreader.client.fragments.BaseFragment.java
protected void showKeyboard(final Activity _context, final EditText _edit) { final InputMethodManager imm = (InputMethodManager) _context.getSystemService(Context.INPUT_METHOD_SERVICE); if (android.os.Build.VERSION.SDK_INT < 11) { imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); }// ww w . j av a 2 s . c o m _edit.postDelayed(new Runnable() { public void run() { _edit.requestFocus(); imm.showSoftInput(_edit, 0); } }, 100); }
From source file:org.tasks.activities.TagSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tag_settings_activity); ButterKnife.bind(this); tagData = getIntent().getParcelableExtra(EXTRA_TAG_DATA); if (tagData == null) { isNewTag = true;// w ww.jav a 2 s . c o m tagData = new TagData(); tagData.setUUID(UUIDHelper.newUUID()); } if (savedInstanceState == null) { selectedTheme = tagData.getColor(); } else { selectedTheme = savedInstanceState.getInt(EXTRA_SELECTED_THEME); } final boolean backButtonSavesTask = preferences.backButtonSavesTask(); toolbar.setTitle(isNewTag ? getString(R.string.new_tag) : tagData.getName()); toolbar.setNavigationIcon(ContextCompat.getDrawable(this, backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)); toolbar.setNavigationOnClickListener(v -> { if (backButtonSavesTask) { discard(); } else { save(); } }); toolbar.inflateMenu(R.menu.menu_tag_settings); toolbar.setOnMenuItemClickListener(this); toolbar.showOverflowMenu(); color.setInputType(InputType.TYPE_NULL); name.setText(tagData.getName()); String autopopulateName = getIntent().getStringExtra(TOKEN_AUTOPOPULATE_NAME); if (!isEmpty(autopopulateName)) { name.setText(autopopulateName); getIntent().removeExtra(TOKEN_AUTOPOPULATE_NAME); } else if (isNewTag) { toolbar.getMenu().findItem(R.id.delete).setVisible(false); name.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT); } updateTheme(); }
From source file:com.mehmetakiftutuncu.eshotroid.activities.BusListActivity.java
private void showHideKeyboard(boolean show) { InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputManager != null && toolbarSearchEditText != null) { if (show) { toolbarSearchEditText.requestFocus(); inputManager.showSoftInput(toolbarSearchEditText, InputMethodManager.SHOW_IMPLICIT); } else {//from www .j a v a 2 s. c om toolbarSearchEditText.clearFocus(); inputManager.hideSoftInputFromWindow(toolbarSearchEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }
From source file:org.catrobat.catroid.ui.dialogs.UploadProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_upload_project, null); projectRename = (TextView) dialogView.findViewById(R.id.tv_project_rename); projectDescriptionField = (EditText) dialogView.findViewById(R.id.project_description_upload); projectUploadName = (EditText) dialogView.findViewById(R.id.project_upload_name); sizeOfProject = (TextView) dialogView.findViewById(R.id.dialog_upload_size_of_project); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.upload_project_dialog_title) .setPositiveButton(R.string.upload_button, new DialogInterface.OnClickListener() { @Override/*w ww . j a v a 2s. c om*/ public void onClick(DialogInterface dialog, int which) { handleUploadButtonClick(); } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleCancelButtonClick(); } }).create(); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { initListeners(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT); } }); initControls(); return dialog; }
From source file:ng.uavp.ch.ngusbterminal.ShellFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.shell, container, false); terminalView = (TerminalEditText) view.findViewById(R.id.editText1); terminalView.HookSerialDevice(serial); recvHandler = new Handler(Looper.getMainLooper()) { @Override/* w w w . j ava2 s . c om*/ public void handleMessage(Message inputMessage) { byte[] receivedData = (byte[]) inputMessage.obj; terminalView.OnReceived(receivedData); } }; if (terminalView.requestFocus()) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(terminalView, InputMethodManager.SHOW_IMPLICIT); } return view; }