Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in API level 1

TransformationMethod

public interface TransformationMethod

android.text.method.TransformationMethod


TextView uses TransformationMethods to do things like replacing the characters of passwords with dots, or keeping the newline characters from causing line breaks in single-line text fields.

Summary

Public methods

abstract CharSequence getTransformation(CharSequence source, View view)

Returns a CharSequence that is a transformation of the source text -- for example, replacing each character with a dot in a password field.

abstract void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect)

This method is called when the TextView that uses this TransformationMethod gains or loses focus.

Public methods

getTransformation

added in API level 1
public abstract CharSequence getTransformation (CharSequence source, 
                View view)

Returns a CharSequence that is a transformation of the source text -- for example, replacing each character with a dot in a password field. Beware that the returned text must be exactly the same length as the source text, and that if the source text is Editable, the returned text must mirror it dynamically instead of doing a one-time copy.

Parameters
source CharSequence

view View

Returns
CharSequence

onFocusChanged

added in API level 1
public abstract void onFocusChanged (View view, 
                CharSequence sourceText, 
                boolean focused, 
                int direction, 
                Rect previouslyFocusedRect)

This method is called when the TextView that uses this TransformationMethod gains or loses focus.

Parameters
view View

sourceText CharSequence

focused boolean

direction int

previouslyFocusedRect Rect