Example usage for android.text Editable toString

List of usage examples for android.text Editable toString

Introduction

In this page you can find the example usage for android.text Editable toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:org.thialfihar.android.apg.ui.SelectPublicKeyFragment.java

@Override
public void afterTextChanged(Editable editable) {
    mCurQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null;
    getLoaderManager().restartLoader(0, null, this);
}

From source file:com.example.dididoit.app.MainActivity.java

@Override
public void onDialogDoneClick(DialogFragment dialog) {
    Editable newItemText = ((EditText) dialog.getDialog().findViewById(R.id.item_name)).getText();
    String newItem;//w  ww. j  a  va  2 s. c om
    // TODO: this should be handled more gracefully by only enabling done button when there
    // is text
    if (null == newItemText) {
        return;
    } else {
        newItem = newItemText.toString();
    }
    // TODO: add to adapter
}

From source file:com.macleod2486.fragment.Map.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.map, container, false);

    //Gets the building lists into an arraylist
    buildingList.clear();/*from  www  .j a  v  a 2s.c  o  m*/
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.intramuralfields)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages)));
    buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls)));
    Collections.sort(buildingList, String.CASE_INSENSITIVE_ORDER);

    completeList.clear();
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages)));
    completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls)));
    Collections.sort(completeList, String.CASE_INSENSITIVE_ORDER);

    //Only puts the building name for the autocomplete text
    for (int index = 0; index < buildingList.size(); index++) {
        buildingList.set(index, buildingList.get(index).substring(0, buildingList.get(index).indexOf(',')));
    }

    search = (AutoCompleteTextView) view.findViewById(R.id.mapSearch);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_dropdown_item_1line, buildingList);
    search.setThreshold(1);
    search.setAdapter(adapter);
    search.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            final Double lat;
            final Double lon;

            final String selection = (String) parent.getItemAtPosition(position);

            latitude = completeList.get(buildingList.indexOf(selection));
            latitude = latitude.substring(latitude.indexOf(",") + 1, latitude.lastIndexOf(","));
            longitude = completeList.get(buildingList.indexOf(selection));
            longitude = longitude.substring(longitude.lastIndexOf(",") + 1);

            lat = Double.parseDouble(latitude);
            lon = Double.parseDouble(longitude);
            navigate = 0;

            final MarkerOptions markerOpt = new MarkerOptions();
            markerOpt.position(new LatLng(lat, lon)).title(selection);
            markerOpt.snippet("Touch marker twice to navigate");

            UT.clear();
            UT.addMarker(markerOpt);
            UT.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 17));
            UT.setOnMarkerClickListener(new OnMarkerClickListener() {
                @Override
                public boolean onMarkerClick(Marker marker) {
                    Log.i("Map", "Marker clicked");

                    navigate++;

                    //If the marker is clicked twice it launches navigation
                    if (navigate == 2) {
                        navigate = 0;

                        String url = "http://maps.google.com/maps?f=d&daddr=" + latitude + "," + longitude
                                + "&dirflg=d";
                        Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
                        intent.setClassName("com.google.android.apps.maps",
                                "com.google.android.maps.MapsActivity");
                        startActivity(intent);
                    }
                    return false;
                }

            });

            imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
        }
    });
    search.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            if (arg0.toString().isEmpty()) {
                clear.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            Log.i("Map", "Text changed");
            clear.setVisibility(View.VISIBLE);
        }
    });

    clear = (ImageButton) view.findViewById(R.id.clearButton);
    clear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            search.setText("");
            clear.setVisibility(View.INVISIBLE);
        }

    });

    //Sets up the map
    setUpUT();

    return view;
}

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/* ww  w  .j a v  a2 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:net.kjmaster.cookiemom.editor.EditDataActivity.java

private void populateTable(final List<CookieTransactions> cookieTransactionsList, Context mContext) {
    edit_data_table.setShrinkAllColumns(true);
    for (final CookieTransactions cookieTransactions : cookieTransactionsList) {
        if ((cookieTransactions.getTransBoxes() != 0) || (cookieTransactions.getTransCash() != 0)) {
            TableRow tr = new TableRow(mContext);
            tr.setTag(cookieTransactions);

            TextView textView = new TextView(mContext);
            textView.setText(java.text.DateFormat.getInstance().format(cookieTransactions.getTransDate()));
            textView.setEnabled(false);//from ww w .j  a  v  a 2s .c o m

            tr.addView(textView);

            TextView textView2 = new TextView(mContext);
            try {
                if (cookieTransactions.getTransScoutId() < 0) {
                    if (cookieTransactions.getTransBoothId() > 0) {
                        textView2.setText(cookieTransactions.getBooth().getBoothLocation());
                    } else {
                        textView2.setText("Cupboard");
                    }
                } else {
                    textView2.setText(cookieTransactions.getScout().getScoutName());
                }
            } catch (Exception e) {
                textView2.setText("");
            }
            textView2.setEnabled(false);
            tr.addView(textView2);

            TextView textView1 = new TextView(mContext);
            textView1.setText(cookieTransactions.getCookieType());
            textView1.setEnabled(false);
            tr.addView(textView1);

            EditText textView3 = new EditText(mContext);
            textView3.setText(cookieTransactions.getTransBoxes().toString());
            textView3.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    if (mActionMode == null) {
                        startActionMode(actionCall);
                    }
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

                }

                @Override
                public void afterTextChanged(Editable editable) {
                    try {
                        cookieTransactions.setTransBoxes(Integer.valueOf(editable.toString()));

                        cookieTransactionsList.add(cookieTransactions);
                        //Main.daoSession.getCookieTransactionsDao().update(cookieTransactions);
                    } catch (Exception ignored) {
                    }
                }
            });
            tr.addView(textView3);

            EditText textView4 = new EditText(mContext);
            textView4.setText(
                    NumberFormat.getCurrencyInstance().format(cookieTransactions.getTransCash().floatValue()));
            textView4.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    if (mActionMode == null) {
                        startActionMode(actionCall);
                    }
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

                }

                @Override
                public void afterTextChanged(Editable editable) {
                    try {

                        cookieTransactions.setTransCash(Double.valueOf(editable.toString()));
                        cookieTransactionsList.add(cookieTransactions);

                    } catch (Exception ignored) {
                    }

                }
            });
            tr.addView(textView4);

            edit_data_table.addView(tr);
        }

    }
}

From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListVendorMetadataActivity.java

private Dialog addMetaAttribute() {
    AlertDialog.Builder publishSaveDialog = createDialog(R.string.add);

    final EditText input = new EditText(this);
    publishSaveDialog.setView(input);/*from www.  j a v a 2  s .  co  m*/

    publishSaveDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            Editable value = input.getText();

            String name = value.toString();
            ContentValues publishValues = new ContentValues();
            publishValues.put(MetaAttributes.COLUMN_NAME, name);
            getContentResolver().insert(Uri.parse(DBContentProvider.VENDOR_METADATA_URI + "/" + lastMetadataID
                    + "/" + DBContentProvider.VENDOR_META_ATTRIBUTES), publishValues);
        }
    });

    publishSaveDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });

    return publishSaveDialog.create();
}

From source file:org.droid2droid.ui.contacts.AbstractSMSFragment.java

@Override
public void afterTextChanged(Editable s) {
    String newText = s.toString();
    mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
    getLoaderManager().restartLoader(LOADER_ID, null, this);
}

From source file:com.gimranov.zandy.app.LookupActivity.java

/**
 * Implementation of the OnClickListener interface, to handle button events.
 * /*  ww w .j  a v a  2s.c  om*/
 * Note: When adding a button, it needs to be added here, but the
 * ClickListener needs to be set in the main onCreate(..) as well.
 */
public void onClick(View v) {
    Log.d(TAG, "Click on: " + v.getId());
    if (v.getId() == R.id.lookupButton) {
        Log.d(TAG, "Trying to start search activity");
        TextView field = (TextView) findViewById(R.id.identifier);
        Editable fieldContents = (Editable) field.getText();
        Bundle b = new Bundle();
        b.putString("mode", "isbn");
        b.putString("identifier", fieldContents.toString());
        this.b = b;
        showDialog(DIALOG_PROGRESS);
    } else {
        Log.w(TAG, "Uncaught click on: " + v.getId());
    }
}

From source file:com.forrestguice.suntimeswidget.settings.ColorChooser.java

private void changeColor() {
    Editable editable = edit.getText();
    int i = editable.toString().indexOf('#');
    if (i != -1) // should start with a #
    {//from   w ww . j a  v a 2s. c o  m
        editable.delete(i, i + 1);
    }
    editable.insert(0, "#");

    while (editable.length() < 3) // supply an alpha value (FF)
    {
        editable.insert(1, "F");
    }
    if (editable.length() == 7) {
        editable.insert(1, "FF");
    }

    while (editable.length() < 9) // fill rest with "0"
    {
        editable.append("0");
    }

    //Log.d("DEBUG", "color is " + editable.toString());
    edit.setText(editable);
    setColor(editable.toString());
    onColorChanged(getColor());
}

From source file:com.battlelancer.seriesguide.ui.ConnectTraktCredentialsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setupViews();/*from w  w w .  j a  v a2 s.  co m*/

    // unfinished task around?
    if (mTask != null && mTask.getStatus() != AsyncTask.Status.FINISHED) {
        // disable buttons, show status message
        setButtonStates(false, false);
        setStatus(true, true, R.string.waitplease);
    }

    // enable e-mail completion via device accounts
    final Account[] accounts = AccountManager.get(getActivity()).getAccounts();
    final Set<String> emailSet = new HashSet<>();
    for (Account account : accounts) {
        if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
            emailSet.add(account.name);
        }
    }
    List<String> emails = new ArrayList<>(emailSet);
    mEmailAutoCompleteView.setAdapter(
            new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, emails));

    // connect button
    mButtonConnect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable buttons, show status message
            setButtonStates(false, false);
            setStatus(true, true, R.string.waitplease);

            // get username and password
            Editable editableUsername = mEditTextUsername.getText();
            String username = editableUsername != null ? editableUsername.toString().trim() : null;
            Editable editablePassword = mEditTextPassword.getText();
            String password = editablePassword != null ? editablePassword.toString().trim() : null;

            // get email
            String email = null;
            if (mCheckBoxNewAccount.isChecked()) {
                Editable editableEmail = mEmailAutoCompleteView.getText();
                email = editableEmail != null ? editableEmail.toString().trim() : null;
            }

            mTask = new ConnectTraktTask(getActivity().getApplicationContext(),
                    ConnectTraktCredentialsFragment.this);
            mTask.execute(username, password, email);
        }
    });

    // disconnect button
    mButtonDisconnect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO do this async
            TraktCredentials.get(getActivity()).removeCredentials();
            setupViews();
        }
    });
}