List of usage examples for android.text InputType TYPE_NUMBER_FLAG_DECIMAL
int TYPE_NUMBER_FLAG_DECIMAL
To view the source code for android.text InputType TYPE_NUMBER_FLAG_DECIMAL.
Click Source Link
From source file:com.checktipsplitter.wizard.model.FreeTextPage.java
@Override public boolean isCompleted() { if (inputType == (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL) || inputType == InputType.TYPE_CLASS_NUMBER) { return !TextUtils.isEmpty(mData.getString(DATA_KEY)) && Float.valueOf(mData.getString(DATA_KEY)) > 0; }/*from w w w .j ava 2 s. co m*/ return !TextUtils.isEmpty( mData.getString(DATA_KEY) != null ? mData.getString(DATA_KEY).trim() : mData.getString(DATA_KEY)); }
From source file:com.softminds.matrixcalculator.dialog_activity.CustomValueFiller.java
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false); if (isDark)/* www . j a va 2 s . c o m*/ setTheme(R.style.AppThemeDarkDialog); else setTheme(R.style.AppThemeDialog); super.onCreate(savedInstanceState); setContentView(R.layout.custom_filler_value); final EditText editText = findViewById(R.id.CustomValue); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DECIMAL_USE", true)) { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); } if (isDark) editText.setTextColor(ContextCompat.getColor(this, R.color.white)); Button button = findViewById(R.id.ConfirmCustomFill); Button exit = findViewById(R.id.CancelCustomFill); button.setAllCaps(true); exit.setAllCaps(true); button.setHeight(50); exit.setHeight(50); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (editText.getText().toString().isEmpty()) Toast.makeText(getApplication(), R.string.NoValue, Toast.LENGTH_SHORT).show(); else { Intent intent = new Intent(); intent.putExtra(Key, Float.parseFloat(editText.getText().toString())); setResult(2, intent); finish(); } } }); exit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); }
From source file:com.jaspersoft.android.jaspermobile.dialog.TextInputControlDialogFragment.java
@NonNull @Override/* ww w. j av a2 s .c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final View customLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_ic_value, null); icValue = (EditText) customLayout.findViewById(R.id.icValue); // allow only numbers if data type is numeric if (mInputControl.getType() == InputControl.Type.singleValueNumber) { icValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL); } String icName = mInputControl.getState().getValue(); icValue.setText(icName); icValue.setSelection(icName.length()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(customLayout); builder.setTitle(mInputControl.getLabel()); builder.setCancelable(false); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newIcValue = TextInputControlDialogFragment.this.icValue.getText().toString(); if (mDialogListener != null) { ((InputControlValueDialogCallback) mDialogListener).onTextValueEntered(mInputControl, newIcValue); } } }); builder.setNegativeButton(R.string.cancel, null); icValueDialog = builder.create(); icValueDialog.setOnShowListener(this); return icValueDialog; }
From source file:com.softminds.matrixcalculator.base_fragments.EditFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View V = inflater.inflate(R.layout.fragment_edit, container, false); CardView cardView = V.findViewById(R.id.EditMatrixCard); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4"); String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd"); cardView.setCardElevation(Integer.parseInt(string)); CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); //noinspection ConstantConditions int index = getArguments().getInt("INDEX"); //noinspection ConstantConditions MatrixV2 m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index); GridLayout gridLayout = new GridLayout(getContext()); gridLayout.setRowCount(m.getNumberOfRows()); gridLayout.setColumnCount(m.getNumberOfCols()); for (int i = 0; i < m.getNumberOfRows(); i++) { for (int j = 0; j < m.getNumberOfCols(); j++) { EditText editText = new EditText(getContext()); editText.setId(i * 10 + j);/* w w w . j a v a2 s . com*/ editText.setBackgroundColor(Color.parseColor(string2)); editText.setGravity(Gravity.CENTER); if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(getLength()) }); if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) { editText.setWidth(ConvertTopx(62)); editText.setTextSize(SizeReturner(3, 3, PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); } else { editText.setWidth(ConvertTopx(CalculatedWidth(m.getNumberOfCols()))); editText.setTextSize(SizeReturner(m.getNumberOfRows(), m.getNumberOfCols(), PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); } editText.setText(SafeSubString(GetText(m.getElementOf(i, j)), getLength())); editText.setSingleLine(); GridLayout.Spec Row = GridLayout.spec(i, 1); GridLayout.Spec Col = GridLayout.spec(j, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col); params.leftMargin = params.topMargin = params.bottomMargin = params.rightMargin = getResources() .getDimensionPixelOffset(R.dimen.border_width); gridLayout.addView(editText, params); } } gridLayout.setLayoutParams(params1); cardView.addView(gridLayout); RootView = V; return V; }
From source file:org.dash.wallet.common.ui.CurrencyAmountView.java
@Override protected void onFinishInflate() { super.onFinishInflate(); final Context context = getContext(); textView = (TextView) getChildAt(0); textView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); textView.setHintTextColor(lessSignificantColor); textView.setHorizontalFadingEdgeEnabled(true); textView.setSingleLine();/* w w w . j a v a 2 s .c om*/ setValidateAmount(textView instanceof EditText); textView.addTextChangedListener(textViewListener); textView.setOnFocusChangeListener(textViewListener); //For layout preview only. if (isInEditMode()) { textView.setText("0.1"); } contextButton = new View(context) { @Override protected void onMeasure(final int wMeasureSpec, final int hMeasureSpec) { setMeasuredDimension(textView.getCompoundPaddingRight(), textView.getMeasuredHeight()); } }; final LayoutParams chooseViewParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); chooseViewParams.gravity = Gravity.RIGHT; contextButton.setLayoutParams(chooseViewParams); this.addView(contextButton); updateAppearance(); }
From source file:uk.ac.horizon.artcodes.fragment.ActionEditDialogFragment.java
@NonNull @Override//from w w w . ja v a2 s . c om public Dialog onCreateDialog(Bundle savedInstanceState) throws NullPointerException { binding = ActionEditBinding.inflate(getActivity().getLayoutInflater()); binding.newMarkerCode.setFilters(new InputFilter[] { new MarkerFormat() }); String currentKeyboard = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); Log.i("Keyboard", currentKeyboard); if (currentKeyboard.contains("com.lge.ime")) { binding.newMarkerCode.setKeyListener(DigitsKeyListener.getInstance("0123456789:")); binding.newMarkerCode.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } binding.newMarkerCode.addTextChangedListener(new SimpleTextWatcher() { @Override public String getText() { return null; } @Override public void onTextChanged(String value) { if (!value.isEmpty()) { binding.newMarkerCode.setText(""); Action action = getAction(); action.getCodes().add(value); ActionCodeBinding codeBinding = createCodeBinding(binding, action, action.getCodes().size() - 1); codeBinding.editMarkerCode.requestFocus(); } } }); binding.scanButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), ScannerActivity.class); intent.putExtra("experience", "{\"name\":\"Scan Code\"}"); startActivityForResult(intent, SCAN_CODE_REQUEST); } }); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(binding.getRoot()); final Dialog dialog = builder.create(); binding.deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getArguments().containsKey("action")) { dialog.dismiss(); final int index = getArguments().getInt("action"); if (getTargetFragment() instanceof ActionEditListFragment) { ((ActionEditListFragment) getTargetFragment()).getAdapter().deleteAction(index); } else { getExperience().getActions().remove(index); } } } }); binding.doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getArguments().containsKey("action")) { updateAction(); // make sure code is sorted if (getAction().getCodes().size() == 1) { // Actions with only 1 code can not be a group or sequence! getAction().setMatch(Action.Match.any); } final int index = getArguments().getInt("action"); if (getTargetFragment() instanceof ActionEditListFragment) { ((ActionEditListFragment) getTargetFragment()).getAdapter().actionUpdated(index); } } dialog.dismiss(); } }); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this.getContext(), R.array.match_type_descriptions, R.layout.match_type_spinner_item); binding.matchSpinner.setAdapter(adapter); binding.matchSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (getAction() != null) { switch (i) { case 0: getAction().setMatch(Action.Match.any); break; case 1: getAction().setMatch(Action.Match.all); break; case 2: getAction().setMatch(Action.Match.sequence); break; } } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); if (Feature.get(getContext(), R.bool.feature_combined_markers).isEnabled()) { binding.selectLayout.setVisibility(View.GONE); binding.matchSpinner.setVisibility(View.VISIBLE); } // Upload to artcodes.co.uk feature button: if (Feature.get(getContext(), R.bool.feature_upload_to_artcodes_co_uk).isEnabled()) { binding.uploadToArtcodesCoUkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { UUID uuid = UUID.randomUUID(); String url = "http://www.artcodes.co.uk/test1234/?file=A" + uuid.toString() + "&source=artcodes-android-app"; getAction().setUrl(url); updateAction(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url + "&dontCheckForFiles")); startActivity(intent); } }); binding.uploadToArtcodesCoUkButton.setVisibility(View.VISIBLE); } return dialog; }
From source file:com.variable.demo.api.fragment.ThermaFragment.java
/** * Builds a Dialog to ask the user to change the emissivity setting. *//* w w w . j a va2 s . co 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//from w ww .j av a 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. ja v a 2 s . c o 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:com.physphil.android.unitconverterultimate.fragments.ConversionFragment.java
@Nullable @Override//from w ww. j a v a2s . co 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; }