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.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 ww . j av a 2 s . c o 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:org.peaklabs.consumer.Escanea.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu2, menu); MenuItem searchItem = menu.findItem(R.id.entrada_manual); searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setQueryHint(getResources().getString(R.string.entrada_manual)); searchView.setInputType(InputType.TYPE_CLASS_NUMBER); final SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { @Override/*ww w. j av a2s .c o m*/ public boolean onQueryTextChange(String newText) { // Do something return true; } @Override public boolean onQueryTextSubmit(String query) { String barcode = searchView.getQuery().toString(); mBarcodePicker.stopScanning(); Intent intent = new Intent(Escanea.this, BuscaProducto.class); intent.putExtra("barcode", barcode); startActivity(intent); finish(); return true; } }; searchView.setOnQueryTextListener(queryTextListener); return super.onCreateOptionsMenu(menu); // true -> el men ya est visible }
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 ww . ja v a 2 s. c o 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:au.org.ala.fielddata.mobile.SurveyBuilder.java
public View buildInput(Attribute attribute, ViewGroup parent) { Record record = model.getRecord();/*ww w.j ava 2 s.co m*/ View view; switch (attribute.getType()) { case STRING: view = buildEditText(InputType.TYPE_CLASS_TEXT, parent); break; case INTEGER: case NUMBER: view = buildEditText(InputType.TYPE_CLASS_NUMBER, parent); break; case DECIMAL: case ACCURACY: view = buildEditText(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL, parent); break; case MULTI_SELECT: case POINT_SOURCE: case STRING_WITH_VALID_VALUES: view = buildSpinner(attribute, parent); break; case CATEGORIZED_MULTI_SELECT: view = buildCategorizedSpinner(attribute, parent); break; case NOTES: view = buildEditText(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE, parent); break; case WHEN: view = buildDatePicker(attribute, record, parent); break; case DWC_TIME: view = buildTimePicker(attribute, record, parent); break; case SPECIES_P: view = buildSpeciesPicker(attribute, parent); break; case POINT: view = buildLocationPicker(attribute, parent); break; case IMAGE: view = buildImagePicker(attribute, parent); break; case SINGLE_CHECKBOX: view = buildSingleCheckbox(attribute, parent); break; case MULTI_CHECKBOX: view = buildMultiSpinner(attribute, parent); break; default: view = buildEditText(InputType.TYPE_CLASS_TEXT, parent); break; } return view; }
From source file:pl.wasat.smarthma.ui.frags.base.BaseCollectionDetailsFragment.java
private AutoCompleteTextView resolvePattern(AutoCompleteTextView autoTextView, String pattern) { if (pattern == null) { autoTextView.setInputType(InputType.TYPE_CLASS_TEXT); return autoTextView; } else if (pattern.equalsIgnoreCase("[0-9]+")) { autoTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); return autoTextView; } else if (pattern.equalsIgnoreCase( "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[\\+\\-][0-9]{2}:[0-9]{2})$")) { autoTextView.setInputType(InputType.TYPE_CLASS_DATETIME); return autoTextView; } else if (pattern.equalsIgnoreCase( "(\\[|\\])(100|[0-9]\\d?),(100|[0-9]\\d?)(\\[|\\])|(\\[|\\])?(100|[0-9]\\d?)|(100|[0-9]\\d?)(\\[|\\])?|\\{(100|[0-9]\\d?),(100|[0-9]\\d?)\\}")) { //autoTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); autoTextView.setKeyListener(new PatternNumberKeyListener()); return autoTextView; } else if (pattern.equalsIgnoreCase( "(\\[|\\])[0-9]+,[0-9]+(\\[|\\])|(\\[|\\])?[0-9]+|[0-9]+(\\[|\\])?|\\{[0-9]+,[0-9]+\\}")) { autoTextView.setKeyListener(new PatternNumberKeyListener()); return autoTextView; } else if (pattern.equalsIgnoreCase( "(\\[|\\])[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?(\\[|\\])|(\\[|\\])?[0-9]+(.[0-9]+)?|[0-9]+(.[0-9]+)?(\\[|\\])?|\\{[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?\\}")) { autoTextView.setKeyListener(new PatternNumberKeyListener()); return autoTextView; } else if (pattern.equalsIgnoreCase( "(\\[|\\])[0-9]+,[0-9]+(\\[|\\])|(\\[|\\])?[0-9]+|[0-9]+(\\[|\\])?|\\{[0-9]+,[0-9]+\\}")) { autoTextView.setKeyListener(new PatternNumberKeyListener()); return autoTextView; }/* w ww.j a v a 2 s. com*/ return autoTextView; }
From source file:com.hoteltrip.android.util.NumberPicker.java
@SuppressWarnings({ "UnusedDeclaration" }) public NumberPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); setOrientation(VERTICAL);/* w ww . j av a 2s . co m*/ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.number_picker, this, true); mHandler = new Handler(); InputFilter inputFilter = new NumberPickerInputFilter(); mNumberInputFilter = new NumberRangeKeyListener(); mIncrementButton = (NumberPickerButton) findViewById(R.id.increment); mIncrementButton.setOnClickListener(this); mIncrementButton.setOnLongClickListener(this); mIncrementButton.setNumberPicker(this); mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement); mDecrementButton.setOnClickListener(this); mDecrementButton.setOnLongClickListener(this); mDecrementButton.setNumberPicker(this); mText = (EditText) findViewById(R.id.timepicker_input); mText.setTypeface(Utils.getHelveticaNeue(context)); mText.setOnFocusChangeListener(this); mText.setOnEditorActionListener(this); mText.setFilters(new InputFilter[] { inputFilter }); mText.setRawInputType(InputType.TYPE_CLASS_NUMBER); if (!isEnabled()) { setEnabled(false); } mText.setFocusable(false); mText.setFocusableInTouchMode(false); // TypedArray a = context.obtainStyledAttributes( attrs, // R.styleable.numberpicker ); // mStart = a.getInt( R.styleable.numberpicker_startRange, DEFAULT_MIN // ); // mEnd = a.getInt( R.styleable.numberpicker_endRange, DEFAULT_MAX ); // mWrap = a.getBoolean( R.styleable.numberpicker_wrap, DEFAULT_WRAP ); // mCurrent = a.getInt( R.styleable.numberpicker_defaultValue, // DEFAULT_VALUE ); mCurrent = Math.max(mStart, Math.min(mCurrent, mEnd)); mText.setText("" + mCurrent); }
From source file:com.pax.pay.trans.action.activity.InputTransData2Activity.java
private void setEditText_date(EditText editText) { SpannableString ss = new SpannableString(getString(R.string.prompt_date_default2)); AbsoluteSizeSpan ass = new AbsoluteSizeSpan(getResources().getDimensionPixelOffset(R.dimen.font_size_large), false);//from www .ja v a 2 s .co m ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); editText.setHint(new SpannedString(ss)); // ??,? editText.setHintTextColor(getResources().getColor(R.color.textEdit_hint)); editText.setInputType(InputType.TYPE_CLASS_NUMBER); editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) }); }
From source file:com.nttec.everychan.chans.fourchan.FourchanModule.java
private void addPasscodePreference(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); PreferenceScreen passScreen = preferenceGroup.getPreferenceManager().createPreferenceScreen(context); passScreen.setTitle("4chan pass"); EditTextPreference passTokenPreference = new EditTextPreference(context); EditTextPreference passPINPreference = new EditTextPreference(context); Preference passLoginPreference = new Preference(context); Preference passClearPreference = new Preference(context); passTokenPreference.setTitle("Token"); passTokenPreference.setDialogTitle("Token"); passTokenPreference.setKey(getSharedKey(PREF_KEY_PASS_TOKEN)); passTokenPreference.getEditText().setSingleLine(); passTokenPreference.getEditText()/*from ww w. ja v a 2 s . c om*/ .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); passPINPreference.setTitle("PIN"); passPINPreference.setDialogTitle("PIN"); passPINPreference.setKey(getSharedKey(PREF_KEY_PASS_PIN)); passPINPreference.getEditText().setSingleLine(); passPINPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); passLoginPreference.setTitle("Log In"); passLoginPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (!useHttps()) Toast.makeText(context, "Using HTTPS even if HTTP is selected", Toast.LENGTH_SHORT).show(); final String token = preferences.getString(getSharedKey(PREF_KEY_PASS_TOKEN), ""); final String pin = preferences.getString(getSharedKey(PREF_KEY_PASS_PIN), ""); final String authUrl = "https://sys.4chan.org/auth"; //only https final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask(); final ProgressDialog passAuthProgressDialog = new ProgressDialog(context); passAuthProgressDialog.setMessage("Logging in"); passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { passAuthTask.cancel(); } }); passAuthProgressDialog.setCanceledOnTouchOutside(false); passAuthProgressDialog.show(); Async.runAsync(new Runnable() { @Override public void run() { try { if (passAuthTask.isCancelled()) return; setPasscodeCookie(null, true); List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("act", "do_login")); pairs.add(new BasicNameValuePair("id", token)); pairs.add(new BasicNameValuePair("pin", pin)); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build(); String response = HttpStreamer.getInstance().getStringFromUrl(authUrl, request, httpClient, null, passAuthTask, false); if (passAuthTask.isCancelled()) return; if (response.contains("Your device is now authorized")) { String passId = null; for (Cookie cookie : httpClient.getCookieStore().getCookies()) { if (cookie.getName().equals("pass_id")) { String value = cookie.getValue(); if (!value.equals("0")) { passId = value; break; } } } if (passId == null) { showToast("Could not get pass id"); } else { setPasscodeCookie(passId, true); showToast("Success! Your device is now authorized."); } } else if (response.contains("Your Token must be exactly 10 characters")) { showToast("Incorrect token"); } else if (response.contains("You have left one or more fields blank")) { showToast("You have left one or more fields blank"); } else if (response.contains("Incorrect Token or PIN")) { showToast("Incorrect Token or PIN"); } else { Matcher m = Pattern .compile("<strong style=\"color: red; font-size: larger;\">(.*?)</strong>") .matcher(response); if (m.find()) { showToast(m.group(1)); } else { showWebView(response); } } } catch (Exception e) { showToast(e.getMessage() == null ? resources.getString(R.string.error_unknown) : e.getMessage()); } finally { passAuthProgressDialog.dismiss(); } } private void showToast(final String message) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); } }); } } private void showWebView(final String html) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { WebView webView = new WebView(context); webView.getSettings().setSupportZoom(true); webView.loadData(html, "text/html", null); new AlertDialog.Builder(context).setView(webView) .setNeutralButton(android.R.string.ok, null).show(); } }); } } }); return true; } }); passClearPreference.setTitle("Reset pass cookie"); passClearPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { setPasscodeCookie(null, true); Toast.makeText(context, "Cookie is reset", Toast.LENGTH_LONG).show(); return true; } }); passScreen.addPreference(passTokenPreference); passScreen.addPreference(passPINPreference); passScreen.addPreference(passLoginPreference); passScreen.addPreference(passClearPreference); preferenceGroup.addPreference(passScreen); }
From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java
/** * Inflates the appropriate view for each datatype * /*from w ww.j a v a 2s . co m*/ * @param attribute * @param savedInstanceState * @return * View */ private View loadViewForAttribute(JSONObject attribute, Bundle savedInstanceState) { LayoutInflater inflater = getLayoutInflater(savedInstanceState); String datatype = attribute.optString(Open311.DATATYPE, Open311.STRING); if (datatype.equals(Open311.STRING) || datatype.equals(Open311.NUMBER) || datatype.equals(Open311.TEXT)) { View v = inflater.inflate(R.layout.list_item_report_attributes_string, null); EditText input = (EditText) v.findViewById(R.id.input); if (datatype.equals(Open311.NUMBER)) { input.setInputType(InputType.TYPE_CLASS_NUMBER); } if (datatype.equals(Open311.TEXT)) { input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); } return v; } else if (datatype.equals(Open311.DATETIME)) { View v = inflater.inflate(R.layout.list_item_report_attributes_datetime, null); TextView input = (TextView) v.findViewById(R.id.input); input.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SherlockDialogFragment picker = new DatePickerDialogFragment(v); picker.show(getActivity().getSupportFragmentManager(), "datePicker"); } }); return v; } else if (datatype.equals(Open311.SINGLEVALUELIST) || datatype.equals(Open311.MULTIVALUELIST)) { JSONArray values = attribute.optJSONArray(Open311.VALUES); int len = values.length(); if (datatype.equals(Open311.SINGLEVALUELIST)) { View v = inflater.inflate(R.layout.list_item_report_attributes_singlevaluelist, null); RadioGroup input = (RadioGroup) v.findViewById(R.id.input); for (int i = 0; i < len; i++) { JSONObject value = values.optJSONObject(i); RadioButton button = (RadioButton) inflater.inflate(R.layout.radiobutton, null); button.setText(value.optString(Open311.KEY)); input.addView(button); } return v; } else if (datatype.equals(Open311.MULTIVALUELIST)) { View v = inflater.inflate(R.layout.list_item_report_attributes_multivaluelist, null); LinearLayout input = (LinearLayout) v.findViewById(R.id.input); for (int i = 0; i < len; i++) { JSONObject value = values.optJSONObject(i); CheckBox checkbox = (CheckBox) inflater.inflate(R.layout.checkbox, null); checkbox.setText(value.optString(Open311.KEY)); input.addView(checkbox); } return v; } } return null; }
From source file:it.uniroma3.android.gpstracklogger.adapters.AdapterTrack.java
private void removeErrors(int position) { final int pos = position; final EditText inputSpeed = new EditText(activity); inputSpeed.setInputType(InputType.TYPE_CLASS_NUMBER); new AlertDialog.Builder(activity).setTitle("Speed Limit (km/h)").setView(inputSpeed) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override//from w w w .ja va 2s .c o m public void onClick(DialogInterface dialog, int which) { String speed = inputSpeed.getText().toString(); if (speed != null && !speed.equals("")) { Session.getController().removeErrorSpeed(pos, Float.valueOf(speed)); Toast.makeText(activity, "Traccia salvata", Toast.LENGTH_SHORT).show(); } dialog.cancel(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); }