List of usage examples for android.view.inputmethod InputMethodManager SHOW_IMPLICIT
int SHOW_IMPLICIT
To view the source code for android.view.inputmethod InputMethodManager SHOW_IMPLICIT.
Click Source Link
From source file:hku.fyp14017.blencode.ui.dialogs.MultiLineTextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_text_multiline_dialog, null); input = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_text_EditMultiLineText); if (getHint() != null) { input.setHint(getHint());// w w w .j a v a 2 s . c o m } input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { getDialog().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); initialize(); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(getTitle()) .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.setCanceledOnTouchOutside(true); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button buttonPositive = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE); buttonPositive.setEnabled(getPositiveButtonEnabled()); setPositiveButtonClickCustomListener(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } }); return dialog; }
From source file:org.catrobat.catroid.ui.dialogs.MultiLineTextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_text_multiline_dialog, null); input = (EditText) dialogView.findViewById(R.id.dialog_text_EditMultiLineText); if (getHint() != null) { input.setHint(getHint());// www. j a v a 2 s . com } input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { getDialog().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); initialize(); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(getTitle()) .setNegativeButton(R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.setCanceledOnTouchOutside(true); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (getDialog() == null) { dismiss(); } else { Button buttonPositive = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE); buttonPositive.setEnabled(getPositiveButtonEnabled()); setPositiveButtonClickCustomListener(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } } }); return dialog; }
From source file:com.liferay.alerts.activity.ComposeActivity.java
protected void showKeyboard() { final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); Runnable runnable = new Runnable() { @Override/* ww w . j a v a2 s.c om*/ public void run() { manager.showSoftInput(_edit, InputMethodManager.SHOW_IMPLICIT); } }; int delay = getResources().getInteger(R.integer.compose_show_keyboard_delay); Handler handler = new Handler(); handler.postDelayed(runnable, delay); _edit.setKeyboardHideListener(new KeyboardHideListener() { @Override public void onHide() { finish(); } }); }
From source file:org.catrobat.catroid.ui.dialogs.NewProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_project, null); newProjectEditText = (EditText) dialogView.findViewById(R.id.project_name_edittext); newProjectEditText.setText(""); newProjectDialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.new_project_dialog_title) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override//from w w w. ja v a2 s .c om public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); newProjectDialog.setCanceledOnTouchOutside(true); newProjectDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); newProjectDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); newProjectDialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (getActivity() == null) { Log.e(TAG, "onShow() Activity was null!"); return; } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(newProjectEditText, InputMethodManager.SHOW_IMPLICIT); ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); newProjectEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (newProjectEditText.length() == 0) { ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); } else { ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(true); } } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButtonClick(); } }); } }); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean shouldBeEmpty = sharedPreferences.getBoolean(SHARED_PREFERENCES_EMPTY_PROJECT, false); emptyProjectCheckBox = (CheckBox) dialogView.findViewById(R.id.project_empty_checkbox); emptyProjectCheckBox.setChecked(shouldBeEmpty); return newProjectDialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.LoginRegisterDialog.java
@Override public Dialog onCreateDialog(Bundle bundle) { View rootView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_login_register, null); usernameEditText = (EditText) rootView.findViewById(hku.fyp14017.blencode.R.id.username); passwordEditText = (EditText) rootView.findViewById(hku.fyp14017.blencode.R.id.password); termsOfUseLinkTextView = (TextView) rootView.findViewById(hku.fyp14017.blencode.R.id.register_terms_link); String termsOfUseUrl = getString(hku.fyp14017.blencode.R.string.about_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(hku.fyp14017.blencode.R.string.register_pocketcode_terms_of_use_text)); termsOfUseLinkTextView.setMovementMethod(LinkMovementMethod.getInstance()); termsOfUseLinkTextView.setText(Html.fromHtml(termsOfUseUrl)); usernameEditText.setText(""); passwordEditText.setText(""); final AlertDialog loginRegisterDialog = new AlertDialog.Builder(getActivity()).setView(rootView) .setTitle(hku.fyp14017.blencode.R.string.login_register_dialog_title) .setPositiveButton(hku.fyp14017.blencode.R.string.login_or_register, null) .setNeutralButton(hku.fyp14017.blencode.R.string.password_forgotten, null).create(); loginRegisterDialog.setCanceledOnTouchOutside(true); loginRegisterDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); loginRegisterDialog.setOnShowListener(new OnShowListener() { @Override/*from w w w . j av a 2 s .c om*/ public void onShow(DialogInterface dialog) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(usernameEditText, InputMethodManager.SHOW_IMPLICIT); Button loginRegisterButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_POSITIVE); loginRegisterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handleLoginRegisterButtonClick(); } }); Button passwordFhkuottenButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_NEUTRAL); passwordFhkuottenButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handlePasswordForgottenButtonClick(); } }); } }); return loginRegisterDialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_new_project, null); newProjectEditText = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.project_name_edittext); newProjectEditText.setText(""); newProjectDialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.new_project_dialog_title) .setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a2 s . co m*/ public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .create(); newProjectDialog.setCanceledOnTouchOutside(true); newProjectDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); newProjectDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); newProjectDialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(newProjectEditText, InputMethodManager.SHOW_IMPLICIT); ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); newProjectEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (newProjectEditText.length() == 0) { ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); } else { ((AlertDialog) newProjectDialog).getButton(Dialog.BUTTON_POSITIVE).setEnabled(true); } } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButtonClick(); } }); } }); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean shouldBeEmpty = sharedPreferences.getBoolean(SHARED_PREFERENCES_EMPTY_PROJECT, false); emptyProjectCheckBox = (CheckBox) dialogView .findViewById(hku.fyp14017.blencode.R.id.project_empty_checkbox); emptyProjectCheckBox.setChecked(shouldBeEmpty); return newProjectDialog; }
From source file:com.app.blockydemo.ui.dialogs.ScriptNameDialog.java
private void handleOnShow(final Dialog dialogEditName) { final Button positiveButton = ((AlertDialog) dialogEditName).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setEnabled(false);//w ww . j av a2 s. c o m EditText dialogEditText = (EditText) dialogEditName.findViewById(R.id.dialog_editor_script_name_edit_text); InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(dialogEditText, InputMethodManager.SHOW_IMPLICIT); dialogEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { String variableName = editable.toString(); positiveButton.setEnabled(true); for (Script local_script : ProjectManager.getInstance().getCurrentSprite().getScriptList()) { if (local_script.getName().equals(variableName) && !local_script.getName().equals(script.getName())) { Toast.makeText(getActivity(), R.string.formula_editor_existing_variable, Toast.LENGTH_SHORT) .show(); positiveButton.setEnabled(false); } } if (editable.length() == 0) { positiveButton.setEnabled(false); } if (editable.toString().equals(script.getName())) { positiveButton.setEnabled(false); } } }); dialogEditText.setText(script.getName()); }
From source file:com.jefftharris.passwdsafe.lib.view.GuiUtils.java
/** * Set the keyboard visibility on a view *///from www . ja va2 s .co m public static void setKeyboardVisible(View v, Context ctx, boolean visible) { InputMethodManager imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE); if (visible) { if (ApiCompat.SDK_VERSION >= ApiCompat.SDK_HONEYCOMB) { imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); } else { imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); } } else { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddEmailDialogFragment.java
/** * Creates dialog/* w w w . j a va 2 s. c om*/ */ @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.catrobat.catroid.ui.dialogs.TextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_text_dialog, null); input = (EditText) dialogView.findViewById(R.id.dialog_text_edit_text); inputTitle = (TextView) dialogView.findViewById(R.id.dialog_text_text_view); if (getHint() != null) { input.setHint(getHint());/* w w w . j a v a 2s . co m*/ } input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { getDialog().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); initialize(); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(getTitle()) .setNegativeButton(R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); onOkButtonHandled(); if (okButtonResult) { dismiss(); } return okButtonResult; } return false; } }); dialog.setCanceledOnTouchOutside(true); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button buttonPositive = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE); buttonPositive.setEnabled(getPositiveButtonEnabled()); setPositiveButtonClickCustomListener(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } }); return dialog; }