本文整理匯總了Java中android.widget.EditText.length方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.length方法的具體用法?Java EditText.length怎麽用?Java EditText.length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.length方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFocusChange
import android.widget.EditText; //導入方法依賴的package包/類
@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();
}
}
示例2: getLine
import android.widget.EditText; //導入方法依賴的package包/類
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();
}
示例3: getLineBeforeCursor
import android.widget.EditText; //導入方法依賴的package包/類
@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();
}
示例4: init
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 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();
}