List of usage examples for android.text InputType TYPE_NUMBER_FLAG_SIGNED
int TYPE_NUMBER_FLAG_SIGNED
To view the source code for android.text InputType TYPE_NUMBER_FLAG_SIGNED.
Click Source Link
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)// w w w .j av a 2s . c om 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. jav a 2 s. c om*/ 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);//from www . j a v a 2 s. c om 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:com.grarak.kerneladiutor.fragments.tools.customcontrols.CreateFragment.java
@Override protected void addItems(List<RecyclerViewItem> items) { mEditTextViews.clear();//from w w w .j av a2 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:com.physphil.android.unitconverterultimate.fragments.ConversionFragment.java
@Nullable @Override// w ww. j av a 2 s. 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; }
From source file:com.stan.createcustommap.MainActivity.java
private void addMarker() { if (mMap != null) { LinearLayout layout = new LinearLayout(MainActivity.this); layout.setLayoutParams(new ActionBar.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); final EditText titleField = new EditText(MainActivity.this); titleField.setHint("Title"); final EditText latField = new EditText(MainActivity.this); latField.setHint("Latitude"); latField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); final EditText longField = new EditText(MainActivity.this); longField.setHint("Longitude"); longField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); layout.addView(titleField);//from w w w. j a v a 2 s .co m layout.addView(latField); layout.addView(longField); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Marker"); builder.setView(layout); AlertDialog alertDialog = builder.create(); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { boolean parsable = true; Double lat = null, lon = null; String strLat = latField.getText().toString(); String strLon = longField.getText().toString(); String strTitle = titleField.getText().toString(); try { lat = Double.parseDouble(strLat); } catch (NumberFormatException ex) { parsable = false; Toast.makeText(MainActivity.this, "Latitude does not contain a parsable double", Toast.LENGTH_LONG).show(); } try { lon = Double.parseDouble(strLon); } catch (NumberFormatException ex) { parsable = false; Toast.makeText(MainActivity.this, "Longitude does not contain a parsable double", Toast.LENGTH_LONG); } if (parsable) { LatLng targetLatLng = new LatLng(lat, lon); MarkerOptions markerOptions = new MarkerOptions().position(targetLatLng).title(strTitle); markerOptions.draggable(true); mMap.addMarker(markerOptions); mMap.moveCamera(CameraUpdateFactory.newLatLng(targetLatLng)); } } }); builder.setNegativeButton("Cancel", null); builder.show(); } else { Toast.makeText(MainActivity.this, "Map not ready", Toast.LENGTH_LONG).show(); } }
From source file:com.softminds.matrixcalculator.base_activities.FillingMatrix.java
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false); boolean SmartFit = preferences.getBoolean("SMART_FIT_KEY", false); if (isDark)/*from w w w .j ava 2s.co m*/ setTheme(R.style.AppThemeDark_NoActionBar); else setTheme(R.style.AppTheme_NoActionBar); super.onCreate(savedInstanceState); Bundle bundle = getIntent().getExtras(); if (bundle == null) { Log.wtf("FillingMatrix", "How the heck, it got called ??"); Toast.makeText(getApplication(), R.string.unexpected_error, Toast.LENGTH_SHORT).show(); finish(); } else { col = bundle.getInt("COL"); row = bundle.getInt("ROW"); } setContentView(R.layout.filler); adCard = findViewById(R.id.AddCardFiller); if (!((GlobalValues) getApplication()).DonationKeyFound()) { AdView adView = findViewById(R.id.adViewFiller); AdRequest adRequest = new AdRequest.Builder().build(); adView.setAdListener(new AdLoadListener(adCard)); adView.loadAd(adRequest); if (getResources() .getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) adCard.setVisibility(View.INVISIBLE); else adCard.setVisibility(View.VISIBLE); } else ((ViewGroup) adCard.getParent()).removeView(adCard); Toolbar toolbar = findViewById(R.id.toolbarFill); setSupportActionBar(toolbar); CardView cardView = findViewById(R.id.DynamicCard); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); 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); GridLayout gridLayout = new GridLayout(getApplicationContext()); gridLayout.setRowCount(row); gridLayout.setColumnCount(col); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { EditText editText = new EditText(getApplication()); editText.setBackgroundColor(Color.parseColor(string2)); editText.setId(i * 10 + j); if (isDark) editText.setTextColor(ContextCompat.getColor(this, R.color.white)); editText.setGravity(Gravity.CENTER); SpannableStringBuilder stringBuilder = new SpannableStringBuilder( "a" + String.valueOf(i + 1) + String.valueOf(j + 1)); stringBuilder.setSpan(new SubscriptSpan(), 1, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); stringBuilder.setSpan(new RelativeSizeSpan(0.75f), 1, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); editText.setHint(stringBuilder); if (!PreferenceManager.getDefaultSharedPreferences(this).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 (SmartFit) { editText.setWidth(ConvertTopx(CalculatedWidth(col))); editText.setTextSize(SizeReturner(row, col, PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getBoolean("EXTRA_SMALL_FONT", false))); } else { editText.setWidth(ConvertTopx(62)); editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getBoolean("EXTRA_SMALL_FONT", false))); } 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); MakeType((Type) (getIntent().getExtras().getSerializable("TYPE"))); if (GetMaximum() < GetMinimum()) { final Snackbar snackbar; snackbar = Snackbar.make(findViewById(R.id.filling_matrix), R.string.Warning3, Snackbar.LENGTH_INDEFINITE); snackbar.show(); snackbar.setAction(getString(R.string.action_settings), new View.OnClickListener() { @Override public void onClick(View view) { snackbar.dismiss(); Intent intent = new Intent(getApplicationContext(), SettingsTab.class); startActivity(intent); finish(); } }); } }
From source file:com.mattprecious.smsfix.library.FixOld.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*from w ww. j a v a2 s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(this); switch (id) { case DIALOG_ID_START_DATE_PICKER: dialog = new DatePickerDialog(this, new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { startCalendar.set(year, monthOfYear, dayOfMonth); updateButtons(); } }, startCalendar.get(Calendar.YEAR), startCalendar.get(Calendar.MONTH), startCalendar.get(Calendar.DAY_OF_MONTH)); break; case DIALOG_ID_START_TIME_PICKER: dialog = new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { startCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); startCalendar.set(Calendar.MINUTE, minute); updateButtons(); } }, startCalendar.get(Calendar.HOUR_OF_DAY), startCalendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(this)); break; case DIALOG_ID_END_DATE_PICKER: dialog = new DatePickerDialog(this, new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { endCalendar.set(year, monthOfYear, dayOfMonth); updateButtons(); } }, endCalendar.get(Calendar.YEAR), endCalendar.get(Calendar.MONTH), endCalendar.get(Calendar.DAY_OF_MONTH)); break; case DIALOG_ID_END_TIME_PICKER: dialog = new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { endCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); endCalendar.set(Calendar.MINUTE, minute); updateButtons(); } }, endCalendar.get(Calendar.HOUR_OF_DAY), endCalendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(this)); break; case DIALOG_ID_OFFSET_PICKER: builder.setTitle(R.string.offset_hours); final EditText editText = new EditText(this); DecimalFormat df = new DecimalFormat("#.###"); editText.setText(df.format(Math.abs(offset) / 3600000f)); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL); builder.setView(editText); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { offset = (long) (Double.parseDouble(editText.getText().toString()) * 3600000); updateButtons(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog = builder.create(); break; case DIALOG_ID_CONFIRM: builder.setTitle(R.string.fix_old_confirm_title); builder.setMessage(R.string.fix_old_confirm_message); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fixMessages(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog = builder.create(); break; default: dialog = null; } return dialog; }
From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); LinearLayout layout = new LinearLayout(mParentActivity); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); mTextViewTitle = new TextView(mParentActivity); LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10); mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); layout.addView(mTextViewTitle, textviewParams); mInputEditText = new EditText(mParentActivity); LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10); layout.addView(mInputEditText, editTextParams); setContentView(layout, layoutParams); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mInputMode = mMsg.inputMode;//ww w .jav a2 s . c o m mInputFlag = mMsg.inputFlag; mReturnType = mMsg.returnType; mMaxLength = mMsg.maxLength; mTextViewTitle.setText(mMsg.title); mInputEditText.setText(mMsg.content); int oldImeOptions = mInputEditText.getImeOptions(); mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); oldImeOptions = mInputEditText.getImeOptions(); switch (mInputMode) { case kEditBoxInputModeAny: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE; break; case kEditBoxInputModeEmailAddr: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case kEditBoxInputModeNumeric: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModePhoneNumber: mInputModeContraints = InputType.TYPE_CLASS_PHONE; break; case kEditBoxInputModeUrl: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; case kEditBoxInputModeDecimal: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModeSingleLine: mInputModeContraints = InputType.TYPE_CLASS_TEXT; break; default: break; } if (mIsMultiline) { mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; } mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints); switch (mInputFlag) { case kEditBoxInputFlagPassword: mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case kEditBoxInputFlagSensitive: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; break; case kEditBoxInputFlagInitialCapsWord: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; case kEditBoxInputFlagInitialCapsSentence: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; break; case kEditBoxInputFlagInitialCapsAllCharacters: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; break; default: break; } mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints); switch (mReturnType) { case kKeyboardReturnTypeDefault: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; case kKeyboardReturnTypeDone: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); break; case kKeyboardReturnTypeSend: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); break; case kKeyboardReturnTypeSearch: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); break; case kKeyboardReturnTypeGo: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); break; default: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; } if (mMaxLength > 0) { mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) }); } Handler initHandler = new Handler(); initHandler.postDelayed(new Runnable() { public void run() { mInputEditText.requestFocus(); mInputEditText.setSelection(mInputEditText.length()); openKeyboard(); } }, 200); mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // if user didn't set keyboard type, // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP' if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN)) { //Log.d("EditBox", "actionId: "+actionId +",event: "+event); mParentActivity.setEditBoxResult(mInputEditText.getText().toString()); closeKeyboard(); dismiss(); return true; } return false; } }); }
From source file:nz.ac.otago.psyanlab.common.designer.program.stage.EditPropPropertiesFragment.java
/** * Creates an edit text entry field that allows the user to enter a * fractional number./*from w ww . j a va2 s . c o m*/ * * @param signedAnnotation * @return EditText */ private View newFloatInputView(boolean isSigned, float f) { EditText view = new EditText(getActivity()); if (isSigned) { view.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { view.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } view.setSingleLine(); view.setText(String.valueOf(f)); return view; }