TextView.setTransformationMethod(new PersonalCapitalTransformationMethod(5, 12, '*'));
class PersonalCapitalTransformationMethod extends PasswordTransformationMethod
{
private int m_Begin;
private int m_End;
private char m_Replacement;
public PersonalCapitalTransformationMethod(int pBegin, int pEnd, char pReplacement)
{
super();
m_Begin = pBegin;
m_End = pEnd;
m_Replacement = pReplacement;
}
@Override
public CharSequence getTransformation(CharSequence pSource, View pView)
{
return new PersonalCapitalCharSequence(pSource);
}
private class PersonalCapitalCharSequence implements CharSequence
{
private CharSequence m_Source;
public PersonalCapitalCharSequence(CharSequence pSource)
{
m_Source = pSource;
}
public char charAt(int pIndex)
{
if (pIndex < m_Begin || pIndex > m_End)
{
return m_Source.charAt(pIndex);
}
return m_Replacement;
}
public int length()
{
return m_Source.length();
}
public CharSequence subSequence(int pStart, int pEnd)
{
return m_Source.subSequence(pStart, pEnd);
}
}
}
留言列表