本文整理汇总了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();
}