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:com.app.blockydemo.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 va 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(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(dialog); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } }); return dialog; }
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;//from w w w . ja v 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:hku.fyp14017.blencode.ui.dialogs.TextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_text_dialog, null); input = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_text_edit_text); inputTitle = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_text_text_view); if (getHint() != null) { input.setHint(getHint());//from w ww. j av a2 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(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.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; }
From source file:net.olejon.mdapp.TasksActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Input manager final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); // Layout/*from w w w . j ava 2 s . com*/ setContentView(R.layout.activity_tasks); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.tasks_toolbar); toolbar.setTitle(getString(R.string.tasks_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Floating action button FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.tasks_fab); floatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new MaterialDialog.Builder(mContext).title(getString(R.string.tasks_dialog_title)) .customView(R.layout.activity_tasks_dialog, true) .positiveText(getString(R.string.tasks_dialog_positive_button)) .negativeText(getString(R.string.tasks_dialog_negative_button)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { EditText taskEditText = (EditText) dialog.findViewById(R.id.tasks_dialog_task); String task = taskEditText.getText().toString().trim(); if (task.equals("")) { mTools.showToast("Du m fylle ut navn p oppgaven", 1); } else { ContentValues contentValues = new ContentValues(); contentValues.put(TasksSQLiteHelper.COLUMN_TASK, task); contentValues.put(TasksSQLiteHelper.COLUMN_CREATED_TIME, ""); contentValues.put(TasksSQLiteHelper.COLUMN_REMINDER_TIME, ""); contentValues.put(TasksSQLiteHelper.COLUMN_COMPLETED, "no"); mSqLiteDatabase.insert(TasksSQLiteHelper.TABLE, null, contentValues); dialog.dismiss(); getTasks(); } } @Override public void onNegative(MaterialDialog dialog) { dialog.dismiss(); } }).showListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); } }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue) .negativeColorRes(R.color.black).autoDismiss(false).show(); } }); Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.fab); floatingActionButton.startAnimation(animation); floatingActionButton.setVisibility(View.VISIBLE); // List mListView = (ListView) findViewById(R.id.tasks_list); // Get tasks getTasks(); // Tip dialog if (!mTools.getSharedPreferencesBoolean("TASKS_HIDE_TIP_DIALOG")) { new MaterialDialog.Builder(mContext).title(getString(R.string.tasks_tip_dialog_title)) .content(getString(R.string.tasks_tip_dialog_message)) .positiveText(getString(R.string.tasks_tip_dialog_positive_button)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { mTools.setSharedPreferencesBoolean("TASKS_HIDE_TIP_DIALOG", true); } }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show(); } }
From source file:com.velli.passwordmanager.FragmentLockScreen.java
@Override public void onResume() { super.onResume(); if (getView() != null) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.SHOW_IMPLICIT); }/* w ww .j a va2 s . c o m*/ }
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 ww w . j a v a 2 s .c om } } else { Log.e(TAG, "toggleView() is called when view or activity is detached from fragment!"); } }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment.java
/** * Creates dialog// w w w . java2s.com */ @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:com.yanzhenjie.album.mvp.BaseView.java
protected final void openInputMethod(View view) { view.requestFocus();/*from www . jav a 2 s .c o m*/ InputMethodManager manager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (manager != null) { manager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); } }
From source file:name.setup.dance.DanceStepApp.java
/** Called when the activity is first created. */ @Override//from w ww . j av a 2 s.com public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "[ACTIVITY] onCreate"); super.onCreate(savedInstanceState); //mStepValue = 0; mPaceValue = 0; setContentView(R.layout.main); mUtils = Utils.getInstance(); String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits mUtils.DeviceName = m_szDevIDShort; Log.v(TAG, "ID: " + m_szDevIDShort); Log.v(TAG, "UTILS: " + mUtils.DeviceName); // user name mTextField = (EditText) findViewById(R.id.name_area); mTextField.setCursorVisible(false); if (!(mUtils.UserName == "My Name")) { mTextField.setText(mUtils.UserName); } mTextField.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // only will trigger it if no physical keyboard is open mgr.showSoftInput(mTextField, InputMethodManager.SHOW_IMPLICIT); mTextField.requestFocus(); mTextField.setCursorVisible(true); mOkayButton.setVisibility(View.VISIBLE); } }); // init okay Button mOkayButton = (Button) findViewById(R.id.okay_button); mOkayButton.setVisibility(View.INVISIBLE); mOkayButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); mTextField.setCursorVisible(false); mTextField.clearFocus(); mUtils.UserName = mTextField.getText().toString(); // post name via HHTP new Thread(new Runnable() { public void run() { if (mIsMetric) { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue); } else { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue * 1.609344f); } } }).start(); mOkayButton.setVisibility(View.INVISIBLE); // Post TOAST MESSAGE Toast.makeText(getApplicationContext(), getText(R.string.name_saved), Toast.LENGTH_SHORT).show(); } }); // init Score Button mScoreButton = (Button) findViewById(R.id.scoreButton); mScoreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click String url = "http://www.setup.nl/tools/dancestep_app/index.php?id=" + mUtils.DeviceName + "&time=" + System.currentTimeMillis(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); }
From source file:org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView.java
@Override public void onFocusChanged(boolean hasFocus, int direction, Rect previous) { super.onFocusChanged(hasFocus, direction, previous); if (hasFocus) { ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(this, InputMethodManager.SHOW_IMPLICIT); }/*from w w w . java 2 s.c o m*/ }