List of usage examples for android.view.inputmethod InputMethodManager showSoftInput
public boolean showSoftInput(View view, int flags)
From source file:name.setup.dance.DanceStepApp.java
/** Called when the activity is first created. */ @Override//from w w w. j a v 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.dharmaseed.android.NavigationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case R.id.action_refresh_server_data: fetchNewDataFromServer();//from www . jav a 2s .c om return true; case R.id.action_search: Log.i("nav", "Search!"); EditText searchBox = (EditText) findViewById(R.id.nav_search_text); if (searchCluster.getVisibility() == View.GONE) { searchCluster.setVisibility(View.VISIBLE); searchBox.requestFocus(); searchBox.setCursorVisible(true); InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(searchBox, 0); } else { clearSearch(searchCluster); } return true; case R.id.action_toggle_starred: starFilterOn = !starFilterOn; setStarButton(); updateDisplayedData(); resetListToTop(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.ferdi2005.secondgram.AndroidUtilities.java
public static void showKeyboard(View view) { if (view == null) { return;// w ww . ja v a 2 s. co m } try { InputMethodManager inputManager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); } catch (Exception e) { FileLog.e(e); } }
From source file:es.usc.citius.servando.calendula.fragments.MedicineCreateOrEditFragment.java
private void showSoftInput() { mNameTextView.postDelayed(new Runnable() { @Override/* w w w . java2s. com*/ public void run() { InputMethodManager keyboard = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(mNameTextView, 0); } }, 10); }
From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java
@OnClick({ R.id.docName, R.id.editBdoc }) public void onChangeContainerName() { saveButton.setVisibility(View.VISIBLE); title.setCursorVisible(true);/*from w w w . j av a 2s.c o m*/ title.setInputType(EditorInfo.TYPE_CLASS_TEXT); InputMethodManager input = (InputMethodManager) getActivity() .getSystemService(Activity.INPUT_METHOD_SERVICE); input.showSoftInput(title, InputMethodManager.SHOW_IMPLICIT); }
From source file:com.barbrdo.app.activities.UserProfileActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed();/*from w w w. j a v a 2 s .c o m*/ return true; case R.id.action_edit: if (isEdit) { updateAccount(); } else { isEdit = true; invalidateOptionsMenu(); editTextFirstName.requestFocus(); editTextPhone.setEnabled(true); editTextFirstName.setEnabled(true); editTextLastName.setEnabled(true); editTextPassword.setEnabled(true); editTextConfirmPassword.setEnabled(true); editTextBio.setEnabled(true); textViewSearchRadius.setEnabled(true); if (user.userType.equalsIgnoreCase(getString(R.string.barber_))) textViewMemberSince.setEnabled(true); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editTextFirstName, InputMethodManager.SHOW_IMPLICIT); getView(R.id.cv_password_change).setVisibility(View.VISIBLE); } return true; } return super.onOptionsItemSelected(item); }
From source file:com.openarc.nirmal.nestle.LoginActivity.java
private void login(final String username, final String password) { try {/*from w w w .jav a 2s . c o m*/ showProgressBar(true); JSONObject jSONObject = new JSONObject(); jSONObject.put("username", username); jSONObject.put("password", password); StringEntity stringEntity = new StringEntity(jSONObject.toString()); AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); asyncHttpClient.post(LoginActivity.this, "http://openarc-rad-pradeepc9.c9users.io/cola_app/public/api/v1/authenticate", stringEntity, "application/json", new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { if (cbLoginRemember.isChecked()) { setLoginCredential(username, password); } loginUserType = getLoginUserType(username); setLastLoginUserAndDate(username); JSONObject jsonObject = new JSONObject(new String(responseBody)); session.setToken(jsonObject.getString("token")); getTokenUser(jsonObject.getString("token")); } catch (Exception e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { showProgressBar(false); switch (statusCode) { case 401: tilUserName.setError("User Name not correct"); tilPassword.setError("Password not correct"); tilUserName.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.showSoftInput(tilUserName, 0); break; case 404: Toast.makeText(LoginActivity.this, "Server not Found", Toast.LENGTH_SHORT).show(); break; case 500: Toast.makeText(LoginActivity.this, "Server Error", Toast.LENGTH_SHORT).show(); break; case 503: Toast.makeText(LoginActivity.this, "Server Offline", Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show(); break; } } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.barbrdo.app.activities.UserProfileActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_profile_picture: captureImage();/* ww w . ja v a 2s.c om*/ break; case R.id.tv_radius: showRadiusDialog(textViewSearchRadius.getText().toString()); break; case R.id.tv_change_password: getView(R.id.cv_password_change).setVisibility(View.VISIBLE); isEdit = true; invalidateOptionsMenu(); editTextPassword.requestFocus(); editTextPassword.setEnabled(true); editTextConfirmPassword.setEnabled(true); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editTextPassword, InputMethodManager.HIDE_IMPLICIT_ONLY); break; case R.id.tv_cancel: utilObj.showAlertDialog(this, R.string.cancel_subscription, R.string.are_you_sure_you_want_to_cancel_subscription, R.string.ok, R.string.cancel, new DialogActionCallback() { @Override public void doOnPositive() { final String appPackageName = getPackageName(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); } @Override public void doOnNegative() { } }); break; case R.id.tv_upgrade: Intent intent = new Intent(mContext, SubscriptionDialogActivity.class); if (user.subscriptionPrice == 0) intent.putExtra(Constants.BundleKeyTag.IS_UPGRADE, false); else intent.putExtra(Constants.BundleKeyTag.IS_UPGRADE, true); intent.putExtra(Constants.BundleKeyTag.IS_USER_PROFILE, true); startActivityForResult(intent, Constants.RequestCodes.APP_SUBSCRIPTION); break; } }
From source file:org.rm3l.ddwrt.mgmt.AbstractRouterMgmtDialogFragment.java
private void openKeyboard(final TextView mTextView) { final InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { // only will trigger it if no physical keyboard is open imm.showSoftInput(mTextView, 0); }//from ww w . j av a 2s .co m }
From source file:com.appsimobile.appsii.module.search.SearchController.java
void focusSearchView() { if (mSearchView != null && isUserVisible()) { mSearchView.requestFocus();//from w ww .j av a2 s. c o m InputMethodManager imm = mInputMethodManager; imm.showSoftInput(mSearchView, InputMethodManager.SHOW_IMPLICIT); } }