# ReplacementTransformationMethod

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#pubctors)\|[Methods](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#inhmethods)  

# ReplacementTransformationMethod

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/text/method/ReplacementTransformationMethod "View this page in Kotlin")\|Java

`
public


abstract
class
ReplacementTransformationMethod
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[TransformationMethod](https://developer.android.com/reference/android/text/method/TransformationMethod)`


`

|---|-----------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.text.method.ReplacementTransformationMethod |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [HideReturnsTransformationMethod](https://developer.android.com/reference/android/text/method/HideReturnsTransformationMethod),[SingleLineTransformationMethod](https://developer.android.com/reference/android/text/method/SingleLineTransformationMethod) |--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [HideReturnsTransformationMethod](https://developer.android.com/reference/android/text/method/HideReturnsTransformationMethod) | This transformation method causes any carriage return characters (\\r) to be hidden by displaying them as zero-width non-breaking space characters (\\ufeff).                               | | [SingleLineTransformationMethod](https://developer.android.com/reference/android/text/method/SingleLineTransformationMethod)   | This transformation method causes any newline characters (\\n) to be displayed as spaces instead of causing line breaks, and causes carriage return characters (\\r) to have no appearance. | |

<br />

*** ** * ** ***

This transformation method causes the characters in the[getOriginal()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getOriginal())array to be replaced by the corresponding characters in the[getReplacement()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getReplacement())array.

## Summary

|                                                                           ### Public constructors                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ReplacementTransformationMethod](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#ReplacementTransformationMethod())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                          ||
|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | ` `[getTransformation](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getTransformation(java.lang.CharSequence,%20android.view.View))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` source, `[View](https://developer.android.com/reference/android/view/View)` v) ` Returns a CharSequence that will mirror the contents of the source CharSequence but with the characters in[getOriginal()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getOriginal())replaced by ones from[getReplacement()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getReplacement()). |
| ` void`                                                                           | ` `[onFocusChanged](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#onFocusChanged(android.view.View,%20java.lang.CharSequence,%20boolean,%20int,%20android.graphics.Rect))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` sourceText, boolean focused, int direction, `[Rect](https://developer.android.com/reference/android/graphics/Rect)` previouslyFocusedRect) ` This method is called when the TextView that uses this TransformationMethod gains or loses focus.                                                                                                               |

|                                                                                                                ### Protected methods                                                                                                                ||
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract char[]` | ` `[getOriginal](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getOriginal())`() ` Returns the list of characters that are to be replaced by other characters when displayed.     |
| ` abstract char[]` | ` `[getReplacement](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getReplacement())`() ` Returns a parallel array of replacement characters for the ones that are to be replaced. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.text.method.TransformationMethod](https://developer.android.com/reference/android/text/method/TransformationMethod)` ` |--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | ` `[getTransformation](https://developer.android.com/reference/android/text/method/TransformationMethod#getTransformation(java.lang.CharSequence,%20android.view.View))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` source, `[View](https://developer.android.com/reference/android/view/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](https://developer.android.com/reference/android/text/method/TransformationMethod#onFocusChanged(android.view.View,%20java.lang.CharSequence,%20boolean,%20int,%20android.graphics.Rect))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` sourceText, boolean focused, int direction, `[Rect](https://developer.android.com/reference/android/graphics/Rect)` previouslyFocusedRect) ` This method is called when the TextView that uses this TransformationMethod gains or loses focus. | ||

## Public constructors

### ReplacementTransformationMethod

```
public ReplacementTransformationMethod ()
```

<br />

<br />

## Public methods

### getTransformation

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public CharSequence getTransformation (CharSequence source, 
                View v)
```

Returns a CharSequence that will mirror the contents of the source CharSequence but with the characters in[getOriginal()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getOriginal())replaced by ones from[getReplacement()](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getReplacement()).

<br />

|           Parameters            ||
|----------|-----------------------|
| `source` | `CharSequence` <br /> |
| `v`      | `View` <br />         |

|                                        Returns                                         ||
|--------------------------------------------------------------------------------|--------|
| [CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | <br /> |

### onFocusChanged

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public 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.

<br />

|                   Parameters                   ||
|-------------------------|-----------------------|
| `view`                  | `View` <br />         |
| `sourceText`            | `CharSequence` <br /> |
| `focused`               | `boolean` <br />      |
| `direction`             | `int` <br />          |
| `previouslyFocusedRect` | `Rect` <br />         |

## Protected methods

### getOriginal

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract char[] getOriginal ()
```

Returns the list of characters that are to be replaced by other characters when displayed.

<br />

|     Returns      ||
|----------|--------|
| `char[]` | <br /> |

### getReplacement

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected abstract char[] getReplacement ()
```

Returns a parallel array of replacement characters for the ones that are to be replaced.

<br />

|     Returns      ||
|----------|--------|
| `char[]` | <br /> |