List of usage examples for android.text InputType TYPE_CLASS_NUMBER
int TYPE_CLASS_NUMBER
To view the source code for android.text InputType TYPE_CLASS_NUMBER.
Click Source Link
From source file:com.variable.demo.api.fragment.ThermaFragment.java
/** * Builds a Dialog to ask the user to change the emissivity setting. *//*from www.ja v a 2 s.c o m*/ public void buildAndShowEmissivityDialog() { final EditText text = new EditText(getActivity()); text.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); text.setHint("Enter a number for the emissivity of the surface."); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Enter an Emissivity Number"); builder.setView(text); builder.setPositiveButton("Change", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String rawText = text.getText().toString(); try { Float emissivity_value = Float.parseFloat(rawText); PreferenceManager.getDefaultSharedPreferences(getActivity()).edit() .putFloat(PREF_EMISSIVITY_NUMBER, emissivity_value).commit(); mHandler.obtainMessage(MessageConstants.MESSAGE_EMISSIVITY_NUMBER_UPDATE).sendToTarget(); } catch (NumberFormatException e) { } } }); builder.setNegativeButton("Cancel", null); builder.create().show(); }
From source file:com.wkovacs64.nipthetip.ui.dialog.InputDialog.java
@NonNull @Override// w w w .j ava 2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // If arguments were present, get the data from them Bundle args = getArguments(); final int field; if (args != null) { field = args.getInt(KEY_FIELD); } else { field = CalcActivity.FIELD_UNDEFINED; } // Build and return the MaterialDialog return new MaterialDialog.Builder(getActivity()).positiveText(R.string.action_ok) .inputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL) .input(R.string.hint_input, R.string.prefill_input, false, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog materialDialog, CharSequence charSequence) { String input = charSequence.toString(); switch (field) { case CalcActivity.FIELD_BILL_AMOUNT: mCallback.onBillAmountInput(input); break; case CalcActivity.FIELD_TIP_PERCENT: mCallback.onTipPercentInput(input); break; case CalcActivity.FIELD_TIP_AMOUNT: mCallback.onTipAmountInput(input); break; case CalcActivity.FIELD_TOTAL_AMOUNT: mCallback.onTotalAmountInput(input); break; case CalcActivity.FIELD_NUMBER_OF_PEOPLE: mCallback.onNumberOfPeopleInput(input); break; case CalcActivity.FIELD_EACH_PERSON_PAYS: mCallback.onEachPersonPaysInput(input); break; default: throw new IllegalArgumentException( TAG + " instantiated" + " using unrecognized field index!"); } } }).build(); }
From source file:com.checktipsplitter.wizard.ui.FreeTextFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mEditText.addTextChangedListener(new TextWatcher() { @Override//from w ww .j a v a2 s . co m public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (inputType == (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL)) { mPage.getData().putString(FreeTextPage.DATA_KEY, (!TextUtils.isEmpty(editable.toString())) ? String.valueOf(Float.valueOf(editable.toString())) : null); } else if (inputType == InputType.TYPE_CLASS_NUMBER) { mPage.getData().putString(FreeTextPage.DATA_KEY, (!TextUtils.isEmpty(editable.toString())) ? String.valueOf(Integer.valueOf(editable.toString())) : null); } else { mPage.getData().putString(FreeTextPage.DATA_KEY, (editable != null) ? editable.toString() : null); } mPage.notifyDataChanged(); } }); }
From source file:ru.orangesoftware.financisto.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account);/*from w w w . j a v a2s. c o m*/ accountTitle = new EditText(this); accountTitle.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); accountTitle.setSingleLine(); issuerName = new EditText(this); issuerName.setSingleLine(); numberText = new EditText(this); numberText.setHint(R.string.card_number_hint); numberText.setSingleLine(); sortOrderText = new EditText(this); sortOrderText.setInputType(InputType.TYPE_CLASS_NUMBER); sortOrderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(3) }); sortOrderText.setSingleLine(); closingDayText = new EditText(this); closingDayText.setInputType(InputType.TYPE_CLASS_NUMBER); closingDayText.setHint(R.string.closing_day_hint); closingDayText.setSingleLine(); paymentDayText = new EditText(this); paymentDayText.setInputType(InputType.TYPE_CLASS_NUMBER); paymentDayText.setHint(R.string.payment_day_hint); paymentDayText.setSingleLine(); amountInput = AmountInput_.build(this); amountInput.setOwner(this); limitInput = AmountInput_.build(this); limitInput.setOwner(this); LinearLayout layout = findViewById(R.id.layout); accountTypeAdapter = new EntityEnumAdapter<>(this, AccountType.values(), false); accountTypeNode = x.addListNodeIcon(layout, R.id.account_type, R.string.account_type, R.string.account_type); ImageView icon = accountTypeNode.findViewById(R.id.icon); icon.setColorFilter(ContextCompat.getColor(this, R.color.holo_gray_light)); cardIssuerAdapter = new EntityEnumAdapter<>(this, CardIssuer.values(), false); cardIssuerNode = x.addListNodeIcon(layout, R.id.card_issuer, R.string.card_issuer, R.string.card_issuer); setVisibility(cardIssuerNode, View.GONE); electronicPaymentAdapter = new EntityEnumAdapter<>(this, ElectronicPaymentType.values(), false); electronicPaymentNode = x.addListNodeIcon(layout, R.id.electronic_payment_type, R.string.electronic_payment_type, R.string.card_issuer); setVisibility(electronicPaymentNode, View.GONE); issuerNode = x.addEditNode(layout, R.string.issuer, issuerName); setVisibility(issuerNode, View.GONE); numberNode = x.addEditNode(layout, R.string.card_number, numberText); setVisibility(numberNode, View.GONE); closingDayNode = x.addEditNode(layout, R.string.closing_day, closingDayText); setVisibility(closingDayNode, View.GONE); paymentDayNode = x.addEditNode(layout, R.string.payment_day, paymentDayText); setVisibility(paymentDayNode, View.GONE); currencyCursor = db.getAllCurrencies("name"); startManagingCursor(currencyCursor); currencyAdapter = TransactionUtils.createCurrencyAdapter(this, currencyCursor); x.addEditNode(layout, R.string.title, accountTitle); currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency, R.string.select_currency); limitInput.setExpense(); limitInput.disableIncomeExpenseButton(); limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput); setVisibility(limitAmountView, View.GONE); Intent intent = getIntent(); if (intent != null) { long accountId = intent.getLongExtra(ACCOUNT_ID_EXTRA, -1); if (accountId != -1) { this.account = db.getAccount(accountId); if (this.account == null) { this.account = new Account(); } } else { selectAccountType(AccountType.valueOf(account.type)); } } if (account.id == -1) { x.addEditNode(layout, R.string.opening_amount, amountInput); amountInput.setIncome(); } noteText = new EditText(this); noteText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); noteText.setLines(2); x.addEditNode(layout, R.string.note, noteText); x.addEditNode(layout, R.string.sort_order, sortOrderText); isIncludedIntoTotals = x.addCheckboxNode(layout, R.id.is_included_into_totals, R.string.is_included_into_totals, R.string.is_included_into_totals_summary, true); if (account.id > 0) { editAccount(); } Button bOK = findViewById(R.id.bOK); bOK.setOnClickListener(arg0 -> { if (account.currency == null) { Toast.makeText(AccountActivity.this, R.string.select_currency, Toast.LENGTH_SHORT).show(); return; } if (Utils.isEmpty(accountTitle)) { accountTitle.setError(getString(R.string.title)); return; } AccountType type = AccountType.valueOf(account.type); if (type.hasIssuer) { account.issuer = Utils.text(issuerName); } if (type.hasNumber) { account.number = Utils.text(numberText); } /********** validate closing and payment days **********/ if (type.isCreditCard) { String closingDay = Utils.text(closingDayText); account.closingDay = closingDay == null ? 0 : Integer.parseInt(closingDay); if (account.closingDay != 0) { if (account.closingDay > 31) { Toast.makeText(AccountActivity.this, R.string.closing_day_error, Toast.LENGTH_SHORT).show(); return; } } String paymentDay = Utils.text(paymentDayText); account.paymentDay = paymentDay == null ? 0 : Integer.parseInt(paymentDay); if (account.paymentDay != 0) { if (account.paymentDay > 31) { Toast.makeText(AccountActivity.this, R.string.payment_day_error, Toast.LENGTH_SHORT).show(); return; } } } account.title = text(accountTitle); account.creationDate = System.currentTimeMillis(); String sortOrder = text(sortOrderText); account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder); account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked(); account.limitAmount = -Math.abs(limitInput.getAmount()); account.note = text(noteText); long accountId = db.saveAccount(account); long amount = amountInput.getAmount(); if (amount != 0) { Transaction t = new Transaction(); t.fromAccountId = accountId; t.categoryId = 0; t.note = getResources().getText(R.string.opening_amount) + " (" + account.title + ")"; t.fromAmount = amount; db.insertOrUpdate(t, null); } AccountWidget.updateWidgets(this); Intent intent1 = new Intent(); intent1.putExtra(ACCOUNT_ID_EXTRA, accountId); setResult(RESULT_OK, intent1); finish(); }); Button bCancel = findViewById(R.id.bCancel); bCancel.setOnClickListener(arg0 -> { setResult(RESULT_CANCELED); finish(); }); }
From source file:com.francetelecom.rd.app.nodessimulator.NodeListActivity.java
private void createIdAlert() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Please, enter your device ID (1 < id < 127)"); // Set an EditText view to get user input final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setView(input);/*w ww .j av a 2s. com*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int id = Integer.parseInt(input.getText().toString()); if (id > 0 && id < 128) { DeviceManager.getInstance().setDeviceId(id); start(); } else { Context context = getApplicationContext(); CharSequence error = "Please enter an id between 1 and 127"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, error, duration); toast.show(); createIdAlert(); } } }); alert.show(); }
From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CreateFragment.java
@Override protected void addItems(List<RecyclerViewItem> items) { mEditTextViews.clear();/* ww w.j av a 2 s . c om*/ mCodeViews.clear(); for (final Items.Setting setting : mSettings) { if (setting.isScript()) { final CodeView codeView = new CodeView(); codeView.setTitle(setting.getName(getActivity())); codeView.setSummary(setting.getDescription(getActivity())); codeView.setRequired(setting.isRequired()); codeView.setCode(setting.getDefault()); codeView.setTesting(setting.getUnit() != Items.Setting.Unit.APPLY); codeView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() { @Override public void onClick(RecyclerViewItem item) { Intent intent = new Intent(getActivity(), EditorActivity.class); intent.putExtra(EditorActivity.TITLE_INTENT, setting.getName(getActivity()).toString()); intent.putExtra(EditorActivity.TEXT_INTENT, codeView.getCode()); startActivityForResult(intent, mSettings.indexOf(setting)); } }); codeView.setOnTestListener(new CodeView.OnTestListener() { @Override public void onTestResult(CodeView codeView, String output) { showFab(); } }); items.add(codeView); mCodeViews.put(setting, codeView); } else if (setting.getUnit() != Items.Setting.Unit.ID) { EditTextView editTextView = new EditTextView(); editTextView.setTitle(setting.getName(getActivity())); if (setting.isRequired()) { editTextView.setHint(getString(R.string.required)); } if (setting.getUnit() == Items.Setting.Unit.INTEGER) { editTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); } editTextView.setText(setting.getDefault()); editTextView.setTextWatcher(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { showFab(); } }); items.add(editTextView); mEditTextViews.put(setting, editTextView); } } }
From source file:mobile.client.iot.pzalejko.iothome.MainActivity.java
private void askForNewTemperatureAlert() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.alert_dialog_title_text)); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_NUMBER); builder.setView(input);//from ww w. ja va2 s . c o m builder.setPositiveButton(getString(R.string.alert_dialog_update_button_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tempAlertValueText.setText(R.string.empty_text_marker); Double alertValue = Double.parseDouble(input.getText().toString()); TemperatureAlertEntity entity = new TemperatureAlertEntity(alertValue); // send a request which will set a new temperature alert value. Event event = new Event(entity, EventSource.LOCAL, EventType.UPDATE_TEMPERATURE_ALERT); Intent outIntent = new Intent(MqttEvent.EVENT_OUT); outIntent.putExtra(MqttEvent.PAYLOAD, event); broadcaster.sendBroadcast(outIntent); } }); builder.setNegativeButton(getString(R.string.alert_dialog_cancel_button_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.nextgis.maplibui.formcontrol.TextEdit.java
@Override public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor, SharedPreferences preferences) throws JSONException { ControlHelper.setClearAction(this); JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY); mFieldName = attributes.getString(JSON_FIELD_NAME_KEY); mIsShowLast = ControlHelper.isSaveLastValue(attributes); boolean enabled = ControlHelper.isEnabled(fields, mFieldName); String value = null;//from ww w . j a va 2 s . c o m if (ControlHelper.hasKey(savedState, mFieldName)) value = savedState.getString(ControlHelper.getSavedStateKey(mFieldName)); else if (null != featureCursor) { // feature exists int column = featureCursor.getColumnIndex(mFieldName); if (column >= 0) value = featureCursor.getString(column); } else { // new feature if (attributes.has(JSON_TEXT_KEY) && !attributes.isNull(JSON_TEXT_KEY)) value = attributes.getString(JSON_TEXT_KEY); if (mIsShowLast) value = preferences.getString(mFieldName, value); } boolean useLogin = attributes.optBoolean(USE_LOGIN); String accountName = element.optString(SyncStateContract.Columns.ACCOUNT_NAME); if (useLogin && !TextUtils.isEmpty(accountName)) { enabled = false; Activity activity = ControlHelper.getActivity(getContext()); if (activity != null) { GISApplication app = (GISApplication) activity.getApplication(); Account account = app.getAccount(accountName); value = app.getAccountLogin(account); } } setEnabled(enabled); setText(value); //let's create control int maxLines = attributes.getInt(JSON_MAX_STRING_COUNT_KEY); if (maxLines < 2) { setSingleLine(true); } else { setMaxLines(maxLines); } int fieldType = NOT_FOUND; for (Field field : fields) { if (field.getName().equals(mFieldName)) { fieldType = field.getType(); break; } } boolean onlyFigures = attributes.getBoolean(JSON_ONLY_FIGURES_KEY); if (onlyFigures) { //check field type switch (fieldType) { default: case GeoConstants.FTInteger: setInputType(InputType.TYPE_CLASS_NUMBER); break; case GeoConstants.FTReal: setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; } } }
From source file:nya.miku.wishmaster.chans.cirno.CirnoModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); EditTextPreference passwordPref = new EditTextPreference(context); passwordPref.setTitle(R.string.iichan_prefs_report_thread); passwordPref.setDialogTitle(R.string.iichan_prefs_report_thread); passwordPref.setSummary(R.string.iichan_prefs_report_thread_summary); passwordPref.setKey(getSharedKey(PREF_KEY_REPORT_THREAD)); passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); passwordPref.getEditText().setSingleLine(); passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) }); preferenceGroup.addPreference(passwordPref); super.addPreferencesOnScreen(preferenceGroup); }
From source file:com.physphil.android.unitconverterultimate.fragments.ConversionFragment.java
@Nullable @Override// w w w. ja v a 2s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_conversion, container, false); mTxtValue = (EditText) v.findViewById(R.id.header_value_from); if (savedInstanceState == null) { String value = mPrefs.getLastValue(); if (mConversionId != Conversion.TEMPERATURE) { // adjust value if it was negative coming from temperature conversion value = value.replace("-", ""); value = value.replace("+", ""); } mTxtValue.setText(value); mTxtValue.setSelection(mTxtValue.getText().length()); } // Only allow negative values for temperature if (mConversionId == Conversion.TEMPERATURE) { mTxtValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { mTxtValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } mTxtResult = (EditText) v.findViewById(R.id.header_value_to); mTxtResult.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Copy text to clipboard android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Conversion Result", ((EditText) v).getText().toString()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), R.string.toast_copied_clipboard, Toast.LENGTH_SHORT).show(); return true; } }); mGrpFrom = (RadioGroup) v.findViewById(R.id.radio_group_from); mGrpTo = (RadioGroup) v.findViewById(R.id.radio_group_to); addUnits(); ObservableScrollView scrollView = (ObservableScrollView) v.findViewById(R.id.list_conversion); FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fab); fab.attachToScrollView(scrollView); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { swapUnits(); } }); return v; }