android.widget.EditText#length ( )源码实例Demo

下面列出了android.widget.EditText#length ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FormatEditText   文件: MainActivity.java
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);
    }
}
 
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();
	}
}
 
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;
}
 
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;
}
 
源代码5 项目: java-n-IDE-for-Android   文件: EditorUtil.java
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();
}
 
源代码6 项目: java-n-IDE-for-Android   文件: EditorUtil.java
@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();
}
 
源代码7 项目: Pinview   文件: Pinview.java
@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();
    }
}
 
源代码8 项目: javaide   文件: EditorUtil.java
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();
}
 
源代码9 项目: FChat   文件: ChatActivity.java
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();
    }
 
源代码10 项目: Memento   文件: ContentDialog.java
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;
}
 
源代码11 项目: Birdays   文件: EditActivity.java
/**
 * 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;
}
 
源代码12 项目: coolreader   文件: DisplayTeaserListFragment.java
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();
	}
}
 
源代码13 项目: coolreader   文件: DisplayOriginalListFragment.java
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();
	}
}
 
源代码14 项目: coolreader   文件: DisplayLightNovelListFragment.java
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();
	}
}
 
源代码15 项目: coolreader   文件: DisplayLightNovelListActivity.java
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();
	}
}
 
源代码16 项目: coolreader   文件: DisplayOriginalListActivity.java
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();
	}
}
 
源代码17 项目: coolreader   文件: DisplayTeaserListActivity.java
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();
	}
}
 
源代码18 项目: Pinview   文件: Pinview.java
/**
 * 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();
}
 
源代码19 项目: DragLinearLayout   文件: NoteActivity.java
@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);
    }
}