TextView.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:Tada 作者:
/**
 * Sets the transformation that is applied to the text that this
 * TextView is displaying.
 *
 * @attr ref android.R.styleable#TextView_password
 * @attr ref android.R.styleable#TextView_singleLine
 */
public final void setTransformationMethod(TransformationMethod method) {
    if (method == mTransformation) {
        // Avoid the setText() below if the transformation is
        // the same.
        return;
    }
    if (mTransformation != null) {
        if (mText instanceof Spannable) {
            ((Spannable) mText).removeSpan(mTransformation);
        }
    }

    mTransformation = method;

    if (method instanceof TransformationMethod2) {
        TransformationMethod2 method2 = (TransformationMethod2) method;
        mAllowTransformationLengthChange = !isTextSelectable() && !(mText instanceof Editable);
        method2.setLengthChangesAllowed(mAllowTransformationLengthChange);
    } else {
        mAllowTransformationLengthChange = false;
    }

    setText(mText);

    if (hasPasswordTransformationMethod()) {
        notifyViewAccessibilityStateChangedIfNeeded(
                AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号