Java Code Examples for android.widget.EditText#length()
The following examples show how to use
android.widget.EditText#length() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayAlternativeNovelListActivity.java From coolreader with MIT License | 6 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); if (language != null) { temp.setParent(AlternativeLanguageInfo.getAlternativeLanguageInfo().get(language).getCategoryInfo()); temp.setStatus(language); executeAddTask(temp); } } else { Toast.makeText(this, "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 2
Source File: MainActivity.java From FormatEditText with MIT License | 6 votes |
private void checkSimpleValid(EditText editText) { if (editText.length() == 0) { editText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } else if (editText.length() == 13) { editText.setCompoundDrawablesWithIntrinsicBounds( null, null, ContextCompat.getDrawable(MainActivity.this, R.drawable.icon_valid), null); } else { editText.setCompoundDrawablesWithIntrinsicBounds( null, null, ContextCompat.getDrawable(MainActivity.this, R.drawable.icon_invalid), null); } }
Example 3
Source File: ContentDialog.java From Memento with MIT License | 5 votes |
public boolean checkEditText(EditText target) { if (target.length() > 0) return true; target.setError(getString(R.string.required)); Animator.create(getContext().getApplicationContext()) .on(getView()) .animate(R.anim.shake); return false; }
Example 4
Source File: DisplayTeaserListActivity.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Category:Teasers"); temp.setStatus(Constants.STATUS_TEASER); executeAddTask(temp); } else { Toast.makeText(this, "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 5
Source File: DisplayOriginalListActivity.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Category:Original"); temp.setStatus(Constants.STATUS_ORIGINAL); executeAddTask(temp); } else { Toast.makeText(this, "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 6
Source File: DisplayLightNovelListActivity.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Main_Page"); executeAddTask(temp); } else { Toast.makeText(this, "沒有輸入", Toast.LENGTH_LONG).show(); } }
Example 7
Source File: DisplayLightNovelListFragment.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Main_Page"); executeAddTask(temp); } else { Toast.makeText(getSherlockActivity(), "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 8
Source File: DisplayOriginalListFragment.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Category:Original"); temp.setStatus(Constants.STATUS_ORIGINAL); executeAddTask(temp); } else { Toast.makeText(getSherlockActivity(), "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 9
Source File: DisplayTeaserListFragment.java From coolreader with MIT License | 5 votes |
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Category:Teasers"); temp.setStatus(Constants.STATUS_TEASER); executeAddTask(temp); } else { Toast.makeText(getSherlockActivity(), "Empty Input", Toast.LENGTH_LONG).show(); } }
Example 10
Source File: EditActivity.java From Birdays with Apache License 2.0 | 5 votes |
/** * Used to update text in updatePerson() method */ private String updateText(EditText editText) { String result = ""; if (editText != null && editText.length() != 0) { result = editText.getText().toString(); } return result; }
Example 11
Source File: ChangePassphraseDialogFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private char[] getEnteredPassphrase(final EditText editText) { int len = editText.length(); char[] passphrase = new char[len]; if (editText.getText() != null) { editText.getText().getChars(0, len, passphrase, 0); } return passphrase; }
Example 12
Source File: ChatActivity.java From FChat with MIT License | 5 votes |
public void iniComponen() { listview = (ListView) findViewById(R.id.listview); btn_send = (Button) findViewById(R.id.btn_send); et_content = (EditText) findViewById(R.id.text_content); btn_send.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // ChatMessage im=new ChatMessage(et_content.getText().toString(), String.valueOf(System.currentTimeMillis()),friend.getId(),friend.getName(),friend.getPhoto()); HashMap hm = new HashMap(); hm.put(Constants.NODE_TEXT, et_content.getText().toString()); hm.put(Constants.NODE_TIMESTAMP, String.valueOf(System.currentTimeMillis())); hm.put(Constants.NODE_RECEIVER_ID, friend.getId()); hm.put(Constants.NODE_RECEIVER_NAME, friend.getName()); hm.put(Constants.NODE_RECEIVER_PHOTO, friend.getPhoto()); hm.put(Constants.NODE_SENDER_ID, set.readSetting(Constants.PREF_MY_ID)); hm.put(Constants.NODE_SENDER_NAME, set.readSetting(Constants.PREF_MY_NAME)); hm.put(Constants.NODE_SENDER_PHOTO, set.readSetting(Constants.PREF_MY_DP)); hm.put(Constants.NODE_IS_READ, false); ref.child(chatNode).push().setValue(hm); et_content.setText(""); hideKeyboard(); } }); et_content.addTextChangedListener(contentWatcher); if (et_content.length() == 0) { btn_send.setVisibility(View.GONE); } hideKeyboard(); }
Example 13
Source File: EditorUtil.java From javaide with GNU General Public License v3.0 | 5 votes |
public static String getLine(EditText editText, int pos) { if (pos < 0 || pos > editText.length()) return ""; int line = LineUtils.getLineFromIndex(pos, editText.getLayout().getLineCount(), editText.getLayout()); int lineStart = editText.getLayout().getLineStart(line); int lineEnd = editText.getLayout().getLineEnd(line); return editText.getText().subSequence(lineStart, lineEnd).toString(); }
Example 14
Source File: Pinview.java From Pinview with MIT License | 5 votes |
@Override public void onFocusChange(View view, boolean isFocused) { if (isFocused && !mCursorVisible) { if (mDelPressed) { currentFocus = view; mDelPressed = false; return; } for (final EditText editText : editTextList) { if (editText.length() == 0) { if (editText != view) { editText.requestFocus(); } else { currentFocus = view; } return; } } if (editTextList.get(editTextList.size() - 1) != view) { editTextList.get(editTextList.size() - 1).requestFocus(); } else { currentFocus = view; } } else if (isFocused && mCursorVisible) { currentFocus = view; } else { view.clearFocus(); } }
Example 15
Source File: EditorUtil.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@NonNull public static String getLineBeforeCursor(EditText editText, int pos) { if (pos < 0 || pos > editText.length()) return ""; int line = LineUtils.getLineFromIndex(pos, editText.getLayout().getLineCount(), editText.getLayout()); int lineStart = editText.getLayout().getLineStart(line); return editText.getText().subSequence(lineStart, pos).toString(); }
Example 16
Source File: EditorUtil.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public static String getLine(EditText editText, int pos) { if (pos < 0 || pos > editText.length()) return ""; int line = LineUtils.getLineFromIndex(pos, editText.getLayout().getLineCount(), editText.getLayout()); int lineStart = editText.getLayout().getLineStart(line); int lineEnd = editText.getLayout().getLineEnd(line); return editText.getText().subSequence(lineStart, lineEnd).toString(); }
Example 17
Source File: PassphrasePromptActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private char[] getEnteredPassphrase(final EditText editText) { int len = editText.length(); char[] passphrase = new char[len]; if (editText.getText() != null) { editText.getText().getChars(0, len, passphrase, 0); } return passphrase; }
Example 18
Source File: NoteActivity.java From DragLinearLayout with MIT License | 4 votes |
@Override public void onFocusChange(View v, boolean hasFocus) { setImeVisibility(noteContainer, hasFocus); EditText editText = (EditText) v; final int index = getNoteIndex(note); if(hasFocus){ editText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); } else { if(editText.length() > 0){ ((ImageView)note.findViewById(R.id.noteIcon)).setImageResource(R.drawable.ic_drag); noteContainer.setViewDraggable(note, note.findViewById(R.id.noteIconContainer)); if(index < noteCount){ // note at index set to new value } else { // new note added at index noteCount++; } editText.setHint(R.string.note_complete_prompt); } else { if(index < noteCount){ // existing note set blank } else if(index < getLastNoteIndex()){ // too many trailing blank notes, remove last one final View noteToDelete = noteContainer.getChildAt(firstNoteIndex + index + 1); noteToDelete.findViewById(R.id.noteText).setEnabled(false); // disable further editing ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(noteToDelete, "alpha", 1, 0); ObjectAnimator xAnimator = ObjectAnimator.ofFloat(noteToDelete, "x", noteToDelete.getLeft(), noteToDelete.getLeft() + 30); AnimatorSet set = new AnimatorSet(); set.playTogether(alphaAnimator, xAnimator); set.setDuration(200); set.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation) { noteContainer.removeView(noteToDelete); } }); set.start(); } } editText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); } }
Example 19
Source File: Pinview.java From Pinview with MIT License | 4 votes |
/** * A method to take care of all the initialisations. * * @param context * @param attrs * @param defStyleAttr */ private void init(Context context, AttributeSet attrs, int defStyleAttr) { this.removeAllViews(); mPinHeight *= DENSITY; mPinWidth *= DENSITY; mSplitWidth *= DENSITY; setWillNotDraw(false); initAttributes(context, attrs, defStyleAttr); params = new LayoutParams(mPinWidth, mPinHeight); setOrientation(HORIZONTAL); createEditTexts(); super.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { boolean focused = false; for (EditText editText : editTextList) { if (editText.length() == 0) { editText.requestFocus(); openKeyboard(); focused = true; break; } } if (!focused && editTextList.size() > 0) { // Focus the last view editTextList.get(editTextList.size() - 1).requestFocus(); } if (mClickListener != null) { mClickListener.onClick(Pinview.this); } } }); // Bring up the keyboard final View firstEditText = editTextList.get(0); if (firstEditText != null) firstEditText.postDelayed(new Runnable() { @Override public void run() { openKeyboard(); } }, 200); updateEnabledState(); }