List of usage examples for android.text Editable toString
public String toString();
From source file:Main.java
public static void setEdittextListener(EditText et, final AlertDialog dialog) { et.addTextChangedListener(new TextWatcher() { @Override/*from ww w . j av a 2 s . c o m*/ public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().isEmpty()) { //disable "create" button if folder name is not specified dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); } else { dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(true); } } }); }
From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java
public static <D extends FhemDevice<D>> TypeHandler<D> handlerForSelectedOption(D device, Context context, final String option, final TargetStateSelectedCallback callback) { SetList setList = device.getSetList(); final SetListValue setListValue = setList.get(option); final DeviceStateRequiringAdditionalInformation specialDeviceState = DeviceStateRequiringAdditionalInformation .deviceStateForFHEM(option); if (setListValue instanceof SetListSliderValue) { final SetListSliderValue sliderValue = (SetListSliderValue) setListValue; return new TypeHandler<D>() { private int dimProgress = 0; @Override/*from w w w .j a v a2 s . c o m*/ public View getContentViewFor(Context context, D device) { TableLayout tableLayout = new TableLayout(context); int initialProgress = 0; if (device instanceof DimmableDevice) { initialProgress = ((DimmableDevice) device).getDimPosition(); } tableLayout.addView(new DeviceDimActionRowFullWidth<D>(initialProgress, sliderValue.getStart(), sliderValue.getStep(), sliderValue.getStop(), null, R.layout.device_detail_seekbarrow_full_width) { @Override public void onStopDim(Context context, D device, int progress) { dimProgress = progress; } @Override public String toDimUpdateText(D device, int progress) { return null; } }.createRow(LayoutInflater.from(context), device)); return tableLayout; } @Override public boolean onPositiveButtonClick(View view, Context context, D device) { callback.onTargetStateSelected(option, "" + dimProgress, device, context); return true; } }; } else if (setListValue instanceof SetListGroupValue) { final SetListGroupValue groupValue = (SetListGroupValue) setListValue; final List<String> groupStates = groupValue.getGroupStates(); return new TypeHandler<D>() { @Override public View getContentViewFor(final Context context, final D device) { ListView listView = new ListView(context); listView.setAdapter( new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, groupStates)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { String selection = groupStates.get(position); callback.onTargetStateSelected(option, selection, device, context); dialog.dismiss(); } }); return listView; } @Override boolean requiresPositiveButton() { return false; } }; } else if (specialDeviceState != null) { return new TypeHandler<D>() { private EditText editText; @Override public View getContentViewFor(Context context, D device) { editText = new EditText(context); return editText; } @Override public boolean onPositiveButtonClick(View view, Context context, D device) { Editable value = editText.getText(); String text = value == null ? "" : value.toString(); if (isValidAdditionalInformationValue(text, specialDeviceState)) { callback.onTargetStateSelected(option, text, device, context); return true; } else { DialogUtil.showAlertDialog(context, R.string.error, R.string.invalidInput); return false; } } }; } else { callback.onTargetStateSelected(option, null, device, context); return null; } }
From source file:it.uniroma2.foundme.studente.FollowCourseActivity.java
public static void populateView(String[] result) { courses = new String[result.length]; System.arraycopy(result, 0, courses, 0, result.length); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); for (int i = 0; i < result.length; i++) { Map<String, String> datum = new HashMap<String, String>(2); if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) { datum.put(Variables_it.COURSE, result[0]); datum.put(Variables_it.PROF, ""); data.add(datum);/*w ww. j a v a2 s . c o m*/ break; } else { String[] items = result[i].split(","); String ap = items[0] + items[1]; datum.put(Variables_it.COURSE, ap); datum.put(Variables_it.PROF, items[2]); data.add(datum); } } //creo l'adapter final SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2, new String[] { Variables_it.COURSE, Variables_it.PROF }, new int[] { android.R.id.text1, android.R.id.text2 }); lvTuttiCorsi.setAdapter(adapter); lvTuttiCorsi.setTextFilterEnabled(true); swipeFollow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff); swipeFollow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeFollow.setRefreshing(true); (new Handler()).postDelayed(new Runnable() { @Override public void run() { swipeFollow.setRefreshing(false); try { getCourse(false); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }, 3000); } }); lvTuttiCorsi.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) alertMessage(courses[position]); } }); lvTuttiCorsi.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) swipeFollow.setEnabled(true); else swipeFollow.setEnabled(false); } }); etFilter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); }
From source file:com.fsck.k9.helper.Utility.java
public static boolean requiredFieldValid(Editable s) { return s != null && requiredFieldValid(s.toString()); }
From source file:net.czlee.debatekeeper.PrepTimeBellsEditActivity.java
private static Bundle createBellBundleFromAddOrEditDialog(final Dialog dialog) { final Spinner typeSpinner = (Spinner) dialog.findViewById(R.id.addPrepTimeBellDialog_typeSpinner); final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.addPrepTimeBellDialog_timePicker); final EditText editText = (EditText) dialog.findViewById(R.id.addPrepTimeBellDialog_editText); int typeSelected = typeSpinner.getSelectedItemPosition(); Bundle bundle = new Bundle(); switch (typeSelected) { case ADD_PREP_TIME_BELL_TYPE_START: case ADD_PREP_TIME_BELL_TYPE_FINISH: // We're using this in hours and minutes, not minutes and seconds int minutes = timePicker.getCurrentHour(); int seconds = timePicker.getCurrentMinute(); long time = minutes * 60 + seconds; if (typeSelected == ADD_PREP_TIME_BELL_TYPE_START) bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_START); else/*from www . j a va 2s .co m*/ bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_FINISH); bundle.putLong(PrepTimeBellsManager.KEY_TIME, time); break; case ADD_PREP_TIME_BELL_TYPE_PERCENTAGE: Editable text = editText.getText(); bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_PROPORTIONAL); Double percentage = Double.parseDouble(text.toString()); double value = percentage / 100; bundle.putDouble(PrepTimeBellsManager.KEY_PROPORTION, value); break; } return bundle; }
From source file:org.mozilla.focus.widget.InlineAutocompleteEditText.java
/** * Get the portion of text that is not marked as autocomplete text. * * @param text Current text content that may include autocomplete text *///from w w w . j a v a 2 s . c o m private static String getNonAutocompleteText(final Editable text) { final int start = text.getSpanStart(AUTOCOMPLETE_SPAN); if (start < 0) { // No autocomplete text; return the whole string. return text.toString(); } // Only return the portion that's not autocomplete text return TextUtils.substring(text, 0, start); }
From source file:com.commonsware.android.sap.MainActivity.java
@Override public void afterTextChanged(Editable s) { shareIntent.putExtra(Intent.EXTRA_TEXT, s.toString()); share.setShareIntent(shareIntent); }
From source file:com.g_node.gca.abstracts.AddNoteDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); final View view = getActivity().getLayoutInflater().inflate(R.layout.add_note_dialog_fragment, null); final String uuid = getArguments().getString("uuid", "uuid not valid"); alertDialogBuilder.setView(view);/*from w w w .jav a2s . co m*/ alertDialogBuilder.setTitle("Add New Note: "); alertDialogBuilder.setPositiveButton("ADD", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EditText noteTextEditText = (EditText) view.findViewById(R.id.noteText); EditText noteTitleEditText = (EditText) view.findViewById(R.id.noteTitle2); String absUUID = uuid; Editable noteText = noteTextEditText.getText(); String y = noteText.toString(); String noteTitle = noteTitleEditText.getText().toString(); //Adding to the DB DatabaseHelper.addInABSTRACT_NOTES(absUUID, noteTitle, y); Toast.makeText(getActivity(), "Note Added - Please Refresh..", Toast.LENGTH_SHORT).show(); // String getNotesQuery = "SELECT ABSTRACT_UUID AS _id, NOTE_TITLE FROM ABSTRACT_NOTES WHERE ABSTRACT_UUID = '" + absUUID + "';"; // AbstractNotesFragment.notesCursor = DatabaseHelper.database.rawQuery(getNotesQuery, null); // AbstractNotesFragment.adapter.notifyDataSetChanged(); dialog.dismiss(); } }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getActivity(), "Cancelled", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); return alertDialogBuilder.create(); }
From source file:com.g_node.gca.abstracts.EditNoteDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); final View view = getActivity().getLayoutInflater().inflate(R.layout.add_note_dialog_fragment, null); final String uuid = getArguments().getString("uuid", "uuid not valid"); final String current_note_id = getArguments().getString("note_id", "note_id not valid"); alertDialogBuilder.setView(view);//from ww w . ja v a 2 s . c o m alertDialogBuilder.setTitle("Edit Note: "); final EditText noteTextEditText = (EditText) view.findViewById(R.id.noteText); final EditText noteTitleEditText = (EditText) view.findViewById(R.id.noteTitle2); //setting previous values String getNotesQuery = "SELECT NOTE_ID, ABSTRACT_UUID, NOTE_TITLE, NOTE_TEXT FROM ABSTRACT_NOTES WHERE NOTE_ID = '" + current_note_id + "';"; Cursor notesCursor = DatabaseHelper.database.rawQuery(getNotesQuery, null); notesCursor.moveToFirst(); String currentNoteTitle = notesCursor.getString(notesCursor.getColumnIndexOrThrow("NOTE_TITLE")); String currentNoteText = notesCursor.getString(notesCursor.getColumnIndexOrThrow("NOTE_TEXT")); noteTitleEditText.setText(currentNoteTitle); noteTextEditText.setText(currentNoteText); alertDialogBuilder.setPositiveButton("Update", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String absUUID = uuid; Editable noteText = noteTextEditText.getText(); String y = noteText.toString(); String noteTitle = noteTitleEditText.getText().toString(); DatabaseHelper.updateNoteABSTRACT_NOTES(current_note_id, noteTitle, y); Toast.makeText(getActivity(), "Updated Note - Please Refresh...", Toast.LENGTH_SHORT).show(); // AbstractNotesFragment.adapter.notifyDataSetChanged(); dialog.dismiss(); } }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getActivity(), "Cancelled", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); return alertDialogBuilder.create(); }
From source file:com.example.android.wizardpager.wizard.ui.SingleTextFieldFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mFieldView.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { }/*from w w w . ja v a 2s . co m*/ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } public void afterTextChanged(Editable editable) { mPage.getData().putString(Page.SIMPLE_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }