本文整理匯總了Java中android.widget.TextView.length方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.length方法的具體用法?Java TextView.length怎麽用?Java TextView.length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.length方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTextChanged
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
TextView text = (TextView)getCurrentFocus();
// Can't be sure if we got the right slot, but move focus to
// the next one if there is a letter in the slot
if (text != null && text.length() > 0)
{
View next = text.focusSearch(View.FOCUS_RIGHT);
if (next != null)
next.requestFocus();
doSearch();
}
}
示例2: truncateText
import android.widget.TextView; //導入方法依賴的package包/類
private void truncateText(@Nullable TextView textView, int maxLength) {
if (textView != null) {
if (textView.length() > maxLength) {
String text = (String) textView.getText();
String newText = text.substring(0, maxLength) + "...";
textView.setText(newText);
}
}
}
示例3: onEditorAction
import android.widget.TextView; //導入方法依賴的package包/類
public boolean onEditorAction(TextView view, int actionId, KeyEvent event)
{
// Check id
switch (actionId)
{
// Do a dictionary search if there is a letter in the slot
case EditorInfo.IME_ACTION_NEXT:
if (view.length() > 0 && !data.getSearching())
doSearch();
break;
}
return false;
}
示例4: doSearch
import android.widget.TextView; //導入方法依賴的package包/類
private void doSearch()
{
// Build a match string
StringBuilder buffer = new StringBuilder();
boolean empty = true;
for (int i = 0; i < length; i++)
{
TextView text = (TextView)letters.getChildAt(i);
// If there is a letter in the slot
if (text.length() > 0)
{
String letter = text.getText().toString();
buffer.append(letter.toLowerCase(Locale.getDefault()));
empty = false;
}
// Wildcard
else
buffer.append(".");
}
// Don't search if no letters
if (empty)
return;
// Match string
String match = buffer.toString();
// Start search task
if (data != null)
{
data.startSearchTask(match, wordList);
search.setEnabled(false);
}
}
示例5: isValid
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public boolean isValid(TextView view) {
return view.length() <= value;
}
示例6: isValid
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public boolean isValid(TextView view) {
return view.length() >= value;
}