Java Code Examples for android.widget.TextView.length()

The following are Jave code examples for showing how to use length() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: crossword   File: Main.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 2
Project: VR-One   File: TopicAdapter.java   View Source Code Vote up 5 votes
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);
        }
    }
}
 
Example 3
Project: crossword   File: Main.java   View Source Code Vote up 5 votes
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;
}
 
Example 4
Project: crossword   File: Main.java   View Source Code Vote up 5 votes
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);
    }
}
 
Example 5
Project: data-binding-validator   File: MaxLengthRule.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(TextView view) {
    return view.length() <= value;
}
 
Example 6
Project: data-binding-validator   File: MinLengthRule.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(TextView view) {
    return view.length() >= value;
}