当前位置: 首页>>代码示例>>Java>>正文


Java QwertyKeyListener类代码示例

本文整理汇总了Java中android.text.method.QwertyKeyListener的典型用法代码示例。如果您正苦于以下问题:Java QwertyKeyListener类的具体用法?Java QwertyKeyListener怎么用?Java QwertyKeyListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QwertyKeyListener类属于android.text.method包,在下文中一共展示了QwertyKeyListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleEdit

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void handleEdit(int start, int end) {
    if (start == -1 || end == -1) {
        // This chip no longer exists in the field.
        dismissDropDown();
        return;
    }
    // This is in the middle of a chip, so select out the whole chip
    // and commit it.
    Editable editable = getText();
    setSelection(end);
    String text = getText().toString().substring(start, end);
    if (!TextUtils.isEmpty(text)) {
        RecipientEntry entry = RecipientEntry.constructFakeEntry(text, isValid(text));
        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        CharSequence chipText = createChip(entry, false);
        int selEnd = getSelectionEnd();
        if (chipText != null && start > -1 && selEnd > -1) {
            editable.replace(start, selEnd, chipText);
        }
    }
    dismissDropDown();
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:23,代码来源:RecipientEditTextView.java

示例2: submitItem

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void submitItem(RecipientEntry entry) {
    if (entry == null) {
        return;
    }
    clearComposingText();

    int end = getSelectionEnd();
    int start = mTokenizer.findTokenStart(getText(), end);

    Editable editable = getText();
    QwertyKeyListener.markAsReplaced(editable, start, end, "");
    CharSequence chip = createChip(entry, false);
    if (chip != null && start >= 0 && end >= 0) {
        editable.replace(start, end, chip);
    }
    sanitizeBetween();
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:18,代码来源:RecipientEditTextView.java

示例3: unselectChip

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
/**
 * Remove selection from this chip. Unselecting a RecipientChip will render
 * the chip without a delete icon and with an unfocused background. This is
 * called when the RecipientChip no longer has focus.
 */
private void unselectChip(DrawableRecipientChip chip) {
    int start = getChipStart(chip);
    int end = getChipEnd(chip);
    Editable editable = getText();
    mSelectedChip = null;
    if (start == -1 || end == -1) {
        Log.w(TAG, "The chip doesn't exist or may be a chip a user was editing");
        setSelection(editable.length());
        commitDefault();
    } else {
        getSpannable().removeSpan(chip);
        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        editable.removeSpan(chip);
        try {
            if (!mNoChips) {
                editable.setSpan(constructChipSpan(chip.getEntry(), false, false),
                        start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        } catch (NullPointerException e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }
    setCursorVisible(true);
    setSelection(editable.length());
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:31,代码来源:TextChipsEditView.java

示例4: handleEdit

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void handleEdit(int start, int end) {
    if (start == -1 || end == -1) {
        // This chip no longer exists in the field.
        dismissDropDown();
        return;
    }
    // This is in the middle of a chip, so select out the whole chip
    // and commit it.
    Editable editable = getText();
    setSelection(end);
    String text = getText().toString().substring(start, end);
    if (!TextUtils.isEmpty(text)) {
        RecipientEntry entry = RecipientEntry.constructFakeEntry(text);
        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        CharSequence chipText = createChip(entry, false);
        int selEnd = getSelectionEnd();
        if (chipText != null && start > -1 && selEnd > -1) {
            editable.replace(start, selEnd, chipText);
        }
    }
    dismissDropDown();
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:23,代码来源:RecipientEditTextView.java

示例5: submitItemAtPosition

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void submitItemAtPosition(int position) {
    RecipientEntry entry = createValidatedEntry(
            (RecipientEntry)getAdapter().getItem(position));
    if (entry == null) {
        return;
    }
    clearComposingText();

    int end = getSelectionEnd();
    int start = mTokenizer.findTokenStart(getText(), end);

    Editable editable = getText();
    QwertyKeyListener.markAsReplaced(editable, start, end, "");
    CharSequence chip = createChip(entry, false);
    if (chip != null && start >= 0 && end >= 0) {
        editable.replace(start, end, chip);
    }
    sanitizeBetween();
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:RecipientEditTextView.java

示例6: handleEdit

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void handleEdit(int start, int end) {
    if (start == -1 || end == -1) {
        // This chip no longer exists in the field.
        dismissDropDown();
        return;
    }
    // This is in the middle of a chip, so select out the whole chip
    // and commit it.
    Editable editable = getText();
    setSelection(end);
    String text = getText().toString().substring(start, end);
    if (!TextUtils.isEmpty(text)) {

        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        CharSequence chipText = createChip(text, false);
        int selEnd = getSelectionEnd();
        if (chipText != null && start > -1 && selEnd > -1) {
            editable.replace(start, selEnd, chipText);
        }
    }
    dismissDropDown();
}
 
开发者ID:pecheur,项目名称:android-chip-edittextview,代码行数:23,代码来源:ChipEditTextView.java

示例7: submitItemAtPosition

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void submitItemAtPosition(int position) {
    CharSequence text = getFilter().convertResultToString(
    		getAdapter().getItem(position));

    if (TextUtils.isEmpty(text)) {
        return;
    }
    
    clearComposingText();

    int end = getSelectionEnd();
    int start = mTokenizer.findTokenStart(getText(), end);

    Editable editable = getText();
    QwertyKeyListener.markAsReplaced(editable, start, end, "");
    CharSequence chip = createChip(text, false);
    if (chip != null && start >= 0 && end >= 0) {
        editable.replace(start, end, chip);
    }
    sanitizeBetween();
}
 
开发者ID:pecheur,项目名称:android-chip-edittextview,代码行数:22,代码来源:ChipEditTextView.java

示例8: handleEdit

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void handleEdit(final int start,final int end)
{
if(start==-1||end==-1)
  {
  // This chip no longer exists in the field.
  dismissDropDown();
  return;
  }
// This is in the middle of a chip, so select out the whole chip
// and commit it.
final Editable editable=getText();
setSelection(end);
final String text=getText().toString().substring(start,end);
if(!TextUtils.isEmpty(text))
  {
  final RecipientEntry entry=RecipientEntry.constructFakeEntry(text,isValid(text));
  QwertyKeyListener.markAsReplaced(editable,start,end,"");
  final CharSequence chipText=createChip(entry,false);
  final int selEnd=getSelectionEnd();
  if(chipText!=null&&start>-1&&selEnd>-1)
    editable.replace(start,selEnd,chipText);
  }
dismissDropDown();
}
 
开发者ID:AndroidDeveloperLB,项目名称:ChipsLibrary,代码行数:25,代码来源:RecipientEditTextView.java

示例9: submitItemAtPosition

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private void submitItemAtPosition(final int position)
{
final RecipientEntry entry=createValidatedEntry(getAdapter().getItem(position));
if(entry==null)
  return;
clearComposingText();
final int end=getSelectionEnd();
final int start=mTokenizer.findTokenStart(getText(),end);
final Editable editable=getText();
QwertyKeyListener.markAsReplaced(editable,start,end,"");
final CharSequence chip=createChip(entry,false);
if(chip!=null&&start>=0&&end>=0)
  editable.replace(start,end,chip);
sanitizeBetween();
if(mChipListener!=null)
  mChipListener.onDataChanged();
}
 
开发者ID:AndroidDeveloperLB,项目名称:ChipsLibrary,代码行数:18,代码来源:RecipientEditTextView.java

示例10: commitChip

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private boolean commitChip(int start, int end, Editable editable) {
    ListAdapter adapter = getAdapter();
    if (adapter != null && adapter.getCount() > 0 && enoughToFilter()
            && end == getSelectionEnd() && !isPhoneQuery()) {
        // choose the first entry.
        submitItemAtPosition(0);
        dismissDropDown();
        return true;
    } else {
        int tokenEnd = mTokenizer.findTokenEnd(editable, start);
        if (editable.length() > tokenEnd + 1) {
            char charAt = editable.charAt(tokenEnd + 1);
            if (charAt == COMMIT_CHAR_COMMA || charAt == COMMIT_CHAR_SEMICOLON) {
                tokenEnd++;
            }
        }
        String text = editable.toString().substring(start, tokenEnd).trim();
        clearComposingText();
        if (text != null && text.length() > 0 && !text.equals(" ")) {
            RecipientEntry entry = createTokenizedEntry(text);
            if (entry != null) {
                QwertyKeyListener.markAsReplaced(editable, start, end, "");
                CharSequence chipText = createChip(entry, false);
                if (chipText != null && start > -1 && end > -1) {
                    editable.replace(start, end, chipText);
                }
            }
            // Only dismiss the dropdown if it is related to the text we
            // just committed.
            // For paste, it may not be as there are possibly multiple
            // tokens being added.
            if (end == getSelectionEnd()) {
                dismissDropDown();
            }
            sanitizeBetween();
            return true;
        }
    }
    return false;
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:41,代码来源:RecipientEditTextView.java

示例11: unselectChip

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
/**
 * Remove selection from this chip. Unselecting a RecipientChip will render
 * the chip without a delete icon and with an unfocused background. This is
 * called when the RecipientChip no longer has focus.
 */
private void unselectChip(DrawableRecipientChip chip) {
    int start = getChipStart(chip);
    int end = getChipEnd(chip);
    Editable editable = getText();
    mSelectedChip = null;
    if (start == -1 || end == -1) {
        Log.w(TAG, "The chip doesn't exist or may be a chip a user was editing");
        setSelection(editable.length());
        commitDefault();
    } else {
        getSpannable().removeSpan(chip);
        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        editable.removeSpan(chip);
        try {
            if (!mNoChips) {
                editable.setSpan(constructChipSpan(chip.getEntry(), false, false),
                        start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        } catch (NullPointerException e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }
    setCursorVisible(true);
    setSelection(editable.length());
    if (mAlternatesPopup != null && mAlternatesPopup.isShowing()) {
        mAlternatesPopup.dismiss();
    }
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:34,代码来源:RecipientEditTextView.java

示例12: replaceText

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
@Override
protected void replaceText(CharSequence text) {
    clearComposingText();
    SpannableStringBuilder ssb = buildSpannableForText(text);
    TokenImageSpan tokenSpan = buildSpanForObject(selectedObject);

    Editable editable = getText();
    int end = getSelectionEnd();
    int start = tokenizer.findTokenStart(editable, end);
    if (start < prefix.length()) {
        start = prefix.length();
    }
    String original = TextUtils.substring(editable, start, end);

    if (editable != null) {
        if (tokenSpan == null) {
            editable.replace(start, end, " ");
        } else if (!allowDuplicates && objects.contains(tokenSpan.getToken())) {
            editable.replace(start, end, " ");
        } else {
            QwertyKeyListener.markAsReplaced(editable, start, end, original);
            editable.replace(start, end, ssb);
            editable.setSpan(tokenSpan, start, start + ssb.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            //spanWatcher.onSpanAdded(editable, tokenSpan, start, start + ssb.length() - 1);
        }
    }
}
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:28,代码来源:TokenCompleteTextView.java

示例13: unselectChip

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
/**
 * Remove selection from this chip. Unselecting a RecipientChip will render
 * the chip without a delete icon and with an unfocused background. This is
 * called when the RecipientChip no longer has focus.
 */
private void unselectChip(RecipientChip chip) {
    int start = getChipStart(chip);
    int end = getChipEnd(chip);
    Editable editable = getText();
    mSelectedChip = null;
    if (start == -1 || end == -1) {
        Log.w(TAG, "The chip doesn't exist or may be a chip a user was editing");
        setSelection(editable.length());
        commitDefault();
    } else {
        getSpannable().removeSpan(chip);
        QwertyKeyListener.markAsReplaced(editable, start, end, "");
        editable.removeSpan(chip);
        try {
            if (!mNoChips) {
                editable.setSpan(constructChipSpan(chip.getEntry(), start, false), start, end,
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        } catch (NullPointerException e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }
    setCursorVisible(true);
    setSelection(editable.length());
    if (mAlternatesPopup != null && mAlternatesPopup.isShowing()) {
        mAlternatesPopup.dismiss();
    }
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:34,代码来源:RecipientEditTextView.java

示例14: replaceText

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
@Override
protected void replaceText(CharSequence text) {
    clearComposingText();
    int end = getSelectionEnd();
    int start = mTokenizer.findTokenStart(getText(), end);
    Editable editable = getText();
    String original = TextUtils.substring(editable, start, end);
    QwertyKeyListener.markAsReplaced(editable, start, end, original);
    editable.replace(start, end, mTokenizer.terminateToken(text));
}
 
开发者ID:restorer,项目名称:gloomy-dungeons-2,代码行数:11,代码来源:MultiAutoCompleteTextView.java

示例15: commitChip

import android.text.method.QwertyKeyListener; //导入依赖的package包/类
private boolean commitChip(int start, int end, Editable editable) {
    ListAdapter adapter = getAdapter();
    if (adapter != null && adapter.getCount() > 0 && enoughToFilter()
            && end == getSelectionEnd()) {
        // choose the first entry.
        submitItemAtPosition(0);
        dismissDropDown();
        return true;
    } else {
        int tokenEnd = mTokenizer.findTokenEnd(editable, start);
        if (editable.length() > tokenEnd + 1) {
            char charAt = editable.charAt(tokenEnd + 1);
            if (charAt == COMMIT_CHAR_COMMA || charAt == COMMIT_CHAR_SEMICOLON) {
                tokenEnd++;
            }
        }
        String text = editable.toString().substring(start, tokenEnd).trim();
        clearComposingText();
        if (text != null && text.length() > 0 && !text.equals(" ")) {
            String entry = createTokenizedEntry(text);
            if (entry != null) {
                QwertyKeyListener.markAsReplaced(editable, start, end, "");
                CharSequence chipText = createChip(entry, false);
                if (chipText != null && start > -1 && end > -1) {
                    editable.replace(start, end, chipText);
                }
            }
            // Only dismiss the dropdown if it is related to the text we
            // just committed.
            // For paste, it may not be as there are possibly multiple
            // tokens being added.
            if (end == getSelectionEnd()) {
                dismissDropDown();
            }
            sanitizeBetween();
            return true;
        }
    }
    return false;
}
 
开发者ID:pecheur,项目名称:android-chip-edittextview,代码行数:41,代码来源:ChipEditTextView.java


注:本文中的android.text.method.QwertyKeyListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。