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:org.openmrs.mobile.activities.fragments.FormPageFragment.java
void addQuestion(Question question, LinearLayout parent) { if (question.getQuestionOptions().getRendering().equals("group")) { LinearLayout questionLL = new LinearLayout(getActivity()); questionLL.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); questionLL.setGravity(Gravity.CENTER); parent.addView(questionLL);/*from w w w . j a v a2s . c om*/ Resources r = getActivity().getResources(); float pxLeftMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxTopMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxRightMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxBottomMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); layoutParams.setMargins(Math.round(pxLeftMargin), Math.round(pxTopMargin), Math.round(pxRightMargin), Math.round(pxBottomMargin)); TextView tv = new TextView(getActivity()); tv.setText(question.getLabel()); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tv.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary)); questionLL.addView(tv, layoutParams); for (Question subquestion : question.getQuestions()) { addQuestion(subquestion, questionLL); } } if (question.getQuestionOptions().getRendering().equals("number")) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); Resources r = getActivity().getResources(); float pxLeftMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxTopMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxRightMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxBottomMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); layoutParams.setMargins(Math.round(pxLeftMargin), Math.round(pxTopMargin), Math.round(pxRightMargin), Math.round(pxBottomMargin)); RangeEditText ed = new RangeEditText(getActivity()); ed.setName(question.getLabel()); if (question.getQuestionOptions().getMax() != null) { ed.setHint(question.getLabel() + " [" + question.getQuestionOptions().getMin() + "-" + question.getQuestionOptions().getMax() + "]"); ed.setUpperlimit(Double.parseDouble(question.getQuestionOptions().getMax())); ed.setLowerlimit(Double.parseDouble(question.getQuestionOptions().getMin())); } else { ed.setHint(question.getLabel()); ed.setLowerlimit(-1.0); ed.setUpperlimit(-1.0); } ed.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); ed.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); int id = InputField.generateViewId(); InputField field = new InputField(); ed.setId(id); field.setId(id); field.setConcept(question.getQuestionOptions().getConcept()); inputFields.add(field); parent.addView(ed, layoutParams); } }
From source file:org.mifos.androidclient.templates.OperationFormActivity.java
public EditText addDecimalNumberFormField(String fieldLabel) { return addFormField(fieldLabel, InputType.TYPE_NUMBER_FLAG_DECIMAL); }
From source file:com.cypress.cysmart.BLEServiceFragments.CSCService.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.cyclingspeed_n_cadence, container, false); mDistanceRan = (TextView) rootView.findViewById(R.id.cycling_distance); mCadence = (TextView) rootView.findViewById(R.id.cadence); mCaloriesBurnt = (TextView) rootView.findViewById(R.id.calories_burnt); mTimer = (Chronometer) rootView.findViewById(R.id.time_counter); mWeightEdittext = (EditText) rootView.findViewById(R.id.weight_data); mWeightEdittext.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); mWeightEdittext.addTextChangedListener(new DecimalTextWatcher(mWeightEdittext)); mProgressDialog = new ProgressDialog(getActivity()); // Setting up chart setupChart(rootView);/*from w w w . ja va2 s . c o m*/ // Start/Stop listener Button start_stop_btn = (Button) rootView.findViewById(R.id.start_stop_btn); start_stop_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Button btn = (Button) v; String buttonText = btn.getText().toString(); String startText = getResources().getString(R.string.blood_pressure_start_btn); String stopText = getResources().getString(R.string.blood_pressure_stop_btn); weightString = mWeightEdittext.getText().toString(); if (weightString.equalsIgnoreCase("")) { weightInt = 0; if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_empty), Toast.LENGTH_SHORT).show(); mCaloriesBurnt.setText("0.00"); } } if (weightString.equalsIgnoreCase(".") || weightString.equalsIgnoreCase("0.") || weightString.equalsIgnoreCase("0")) { weightInt = 0; if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_empty), Toast.LENGTH_SHORT).show(); } } if (weightInt <= 1.0 && weightInt != 0) { if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_zero), Toast.LENGTH_SHORT).show(); mCaloriesBurnt.setText("0.00"); } } if (weightInt <= 200) { if (buttonText.equalsIgnoreCase(startText)) { btn.setText(stopText); mCaloriesBurnt.setText("0.00"); mWeightEdittext.setEnabled(false); if (mNotifyCharacteristic != null) { stopBroadcastDataNotify(mNotifyCharacteristic); } getGattData(); mTimer.start(); mTimer.setBase(SystemClock.elapsedRealtime()); mTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer chronometer) { showCaloriesBurnt(); } }); } else { mWeightEdittext.setEnabled(true); btn.setText(startText); stopBroadcastDataNotify(mNotifyCharacteristic); mTimer.stop(); } } else { if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_greater), Toast.LENGTH_SHORT).show(); btn.setText(stopText); mCaloriesBurnt.setText("0.00"); mWeightEdittext.setEnabled(false); if (mNotifyCharacteristic != null) { stopBroadcastDataNotify(mNotifyCharacteristic); } getGattData(); mTimer.start(); mTimer.setBase(SystemClock.elapsedRealtime()); mTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer chronometer) { showCaloriesBurnt(); } }); } else { mWeightEdittext.setEnabled(true); btn.setText(startText); stopBroadcastDataNotify(mNotifyCharacteristic); mCaloriesBurnt.setText("0.00"); mTimer.stop(); } } } }); setHasOptionsMenu(true); return rootView; }
From source file:com.cypress.cysmart.BLEServiceFragments.RSCService.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.runningspeed_n_cadence, container, false); mDistanceRan = (TextView) rootView.findViewById(R.id.running_distance); mAverageSpeed = (TextView) rootView.findViewById(R.id.running_speed); mCaloriesBurnt = (TextView) rootView.findViewById(R.id.calories_burnt); mTimer = (Chronometer) rootView.findViewById(R.id.time_counter); mWeightEdittext = (EditText) rootView.findViewById(R.id.weight_data); mWeightEdittext.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); mWeightEdittext.addTextChangedListener(new DecimalTextWatcher(mWeightEdittext)); mProgressDialog = new ProgressDialog(getActivity()); // Setting up chart setupChart(rootView);//from w w w . j a va 2s . c o m // Start/Stop listener Button start_stop_btn = (Button) rootView.findViewById(R.id.start_stop_btn); start_stop_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Button btn = (Button) v; String buttonText = btn.getText().toString(); String startText = getResources().getString(R.string.blood_pressure_start_btn); String stopText = getResources().getString(R.string.blood_pressure_stop_btn); weightString = mWeightEdittext.getText().toString(); if (weightString.equalsIgnoreCase("")) { weightInt = 0; if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_empty), Toast.LENGTH_SHORT).show(); mCaloriesBurnt.setText("0.00"); } } if (weightString.equalsIgnoreCase(".") || weightString.equalsIgnoreCase("0.") || weightString.equalsIgnoreCase("0")) { weightInt = 0; if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_empty), Toast.LENGTH_SHORT).show(); } } if (weightInt <= 1.0 && weightInt != 0) { if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_zero), Toast.LENGTH_SHORT).show(); mCaloriesBurnt.setText("0.00"); } } if (weightInt <= 200) { if (buttonText.equalsIgnoreCase(startText)) { btn.setText(stopText); mCaloriesBurnt.setText("0.00"); mWeightEdittext.setEnabled(false); if (mNotifyCharacteristic != null) { stopBroadcastDataNotify(mNotifyCharacteristic); } getGattData(); mTimer.start(); mTimer.setBase(SystemClock.elapsedRealtime()); mTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer chronometer) { showCaloriesBurnt(); } }); } else { mWeightEdittext.setEnabled(true); btn.setText(startText); stopBroadcastDataNotify(mNotifyCharacteristic); mTimer.stop(); } } else { if (buttonText.equalsIgnoreCase(startText)) { Toast.makeText(getActivity(), getResources().getString(R.string.csc_weight_toast_greater), Toast.LENGTH_SHORT).show(); btn.setText(stopText); mCaloriesBurnt.setText("0.00"); mWeightEdittext.setEnabled(false); if (mNotifyCharacteristic != null) { stopBroadcastDataNotify(mNotifyCharacteristic); } getGattData(); mTimer.start(); mTimer.setBase(SystemClock.elapsedRealtime()); mTimer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { @Override public void onChronometerTick(Chronometer chronometer) { showCaloriesBurnt(); } }); } else { mWeightEdittext.setEnabled(true); btn.setText(startText); stopBroadcastDataNotify(mNotifyCharacteristic); mCaloriesBurnt.setText("0.00"); mTimer.stop(); } } } }); setHasOptionsMenu(true); return rootView; }
From source file:org.trosnoth.serveradmin.ServerSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); telnet = ConnectionActivity.telnet;//from w ww . j a va2s . c o m telnet.send("game = getGame()"); pref = new ServerSettings(); pref.registerOnSharedPreferenceChangeListener(this); addPreferencesFromResource(R.xml.server_settings); gameModes = telnet.parseJSON(telnet.readWrite("print json.dumps(getGame().listGameModes())")); ListPreference gameModesPref = (ListPreference) this.findPreference("gameMode"); String[] strArray = new String[gameModes.size()]; gameModes.toArray(strArray); gameModesPref.setEntries(strArray); gameModesPref.setEntryValues(strArray); EditTextPreference setting; EditText settingText; setting = (EditTextPreference) findPreference("playersPerTeam"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("playersTotal"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("gameSpeed"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); // Update every 5 seconds Runnable looper = new Runnable() { public void run() { update(); mHandler.postDelayed(this, ConnectionActivity.UPDATE_FREQ); } }; if (ConnectionActivity.automaticUpdate) { mHandler.removeCallbacks(looper); mHandler.post(looper); } else { update(); } }
From source file:com.mattprecious.smsfix.library.FixOld.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*www . j av a 2 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:eu.geopaparazzi.core.maptools.FeaturePageAdapter.java
private TextView getEditView(final Feature feature, final String fieldName, EDataType type, String value) { final TextView editView; switch (type) { case DATE:// www.j a va 2 s .com editView = new TextView(context); editView.setInputType(InputType.TYPE_CLASS_DATETIME); editView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FeaturePageAdapter.this.openDatePicker((EditText) view); } }); if (value == null || value.equals("")) { value = "____-__-__"; } break; default: editView = new EditText(context); break; } editView.setText(value); switch (type) { case DOUBLE: case FLOAT: editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; case PHONE: editView.setInputType(InputType.TYPE_CLASS_PHONE); break; case DATE: editView.setInputType(InputType.TYPE_CLASS_DATETIME); editView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FeaturePageAdapter.this.openDatePicker((TextView) view); } }); break; case INTEGER: editView.setInputType(InputType.TYPE_CLASS_NUMBER); break; default: break; } editView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // ignore } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } public void afterTextChanged(Editable s) { String text = editView.getText().toString(); feature.setAttribute(fieldName, text); } }); return editView; }
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;//w w w .ja va 2 s . c om 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 w w .j av a2 s .c om * * @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; }
From source file:uk.ac.horizon.artcodes.fragment.ActionEditDialogFragment.java
private ActionCodeBinding createCodeBinding(final ActionEditBinding binding, final Action action, final int codeIndex) { final String code = action.getCodes().get(codeIndex); final ActionCodeBinding codeBinding = ActionCodeBinding.inflate(getActivity().getLayoutInflater(), binding.markerCodeList, false); codeBinding.editMarkerCode.setText(code); String currentKeyboard = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); if (currentKeyboard.contains("com.lge.ime")) { codeBinding.editMarkerCode.setKeyListener(DigitsKeyListener.getInstance("0123456789:")); codeBinding.editMarkerCode//from w w w. ja va 2s.c o m .setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } codeBinding.editMarkerCode.setFilters(new InputFilter[] { new MarkerFormat() }); codeBinding.editMarkerCode.addTextChangedListener(new SimpleTextWatcher() { @Override public String getText() { return null; } @Override public void onTextChanged(String value) { if (value.isEmpty()) { action.getCodes().remove(codeIndex); updateCodes(binding, action); binding.newMarkerCode.requestFocus(); } else { action.getCodes().set(codeIndex, value); } } }); binding.markerCodeList.addView(codeBinding.getRoot()); return codeBinding; }