From 3bb766756b77e44558ef107981b8b4f7e48646a5 Mon Sep 17 00:00:00 2001 From: Drew Hudec Date: Fri, 6 Jan 2023 12:36:15 -0500 Subject: [PATCH] feat: Documenting Android setValueRef and isEditable properties (#22) --- docs/sdks/mobile/android/types.mdx | 36 ++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/docs/sdks/mobile/android/types.mdx b/docs/sdks/mobile/android/types.mdx index f2228b0d..761311dc 100644 --- a/docs/sdks/mobile/android/types.mdx +++ b/docs/sdks/mobile/android/types.mdx @@ -2,6 +2,8 @@ sidebar_label: Types --- +import { Alert } from "@site/src/components/shared/Alert"; + # Android Element Types ## TextElement @@ -39,25 +41,45 @@ The following additional properties are supported when programmatically interact | Name | Type | Description | |---------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| text | `String` | Sets the text value for the element. Note that a getter is not exposed on the TextElement to retrieve the underlying text value. | -| textColor | `Int` | A color value in the form `0xAARRGGBB`. Do not pass a resource ID. To get a color value from a resource ID, call [getColor](https://developer.android.com/reference/android/content/res/TypedArray#getColor(int,%20int)). | | hint | `String` | Placeholder text to display within the element when empty. | -| removeDefaultStyles | `Boolean` | Removes the default Android styling on the underlying EditText. | +| isEditable | `Boolean` | Whether this element is editable or readonly. | +| keyboardType | `KeyboardType` | The type of keyboard to display when editing. Supported values are `KeyboardType.TEXT` and `KeyboardType.NUMBER`. | | mask | `ElementMask` | Restricts and formats input entered into this Element. See the [Mask](./options#mask) options for details. | +| removeDefaultStyles | `Boolean` | Removes the default Android styling on the underlying EditText. Defaults to `true`. | +| textColor | `Int` | A color value in the form `0xAARRGGBB`. Do not pass a resource ID. To get a color value from a resource ID, call [getColor](https://developer.android.com/reference/android/content/res/TypedArray#getColor(int,%20int)). | +| textSize | `Float` | The font size, in pixels. | | transform | `ElementTransform` | Transforms the value of this Element prior to tokenization. See the [Transform](./options#transform) options for details. | | validator | `ElementValidator` | Validates the value of this Element within ChangeEvents. See the [Validator](./options#validator) options for details. | +#### Methods + +| Signature | Description | +|-----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `addBlurEventListener(listener: (BlurEvent) -> Unit)` | Adds a listener for any [BlurEvents](./events#blurevent) raised by this element. | +| `addChangeEventListener(listener: (ChangeEvent) -> Unit)` | Adds a listener for any [ChangeEvents](./events#changeevent) raised by this element. | +| `addFocusEventListener(listener: (FocusEvent) -> Unit)` | Adds a listener for any [FocusEvents](./events#focusevent) raised by this element. | +| `setText(value: String?)` | Sets the text value for the element. Note that a getter is not exposed on the TextElement to retrieve the underlying text value. | +| `setValueRef(element: TextElement)` | Binds the provided `element: TextElement` instance as a value source for this element, keeping the value of this element in sync with any changes made to the other element. | + + + When using setValueRef to keep a TextElement in sync with another element, it is strongly recommended that + you make the dependent element readonly by also setting isEditable=false. + + #### XML Attributes The following additional XML attributes are also supported when defining a `TextElement` in a layout XML file: | Name | Type | Description | |---------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| text | `String` | Sets the text value for the element. Note that a getter is not exposed on the TextElement to retrieve the underlying text value. | -| textColor | `reference`|`color` | The text color.

May be a reference to another resource, in the form `"@[+][package:]type/name"` or a theme attribute in the form `"?[package:]type/name"`.

May be a color value, in the form of `"#rgb"`, `"#argb"`, `"#rrggbb"`, or `"#aarrggbb"` | +| editable | `boolean` | Whether this element is editable or readonly. | | hint | `String` | Placeholder text to display within the Element. | -| removeDefaultStyles | `Boolean` | Removes the default Android styling on the underlying EditText. | -| mask | `String` | A string defining the [mask](./options#mask) applied to this Element, e.g. (`###-##-####`). | +| keyboardType | `enum` | The type of keyboard to display when editing. Supported values are `text` and `number`. | +| mask | `string` | A string defining the [mask](./options#mask) applied to this Element, e.g. (`###-##-####`). | +| removeDefaultStyles | `boolean` | Removes the default Android styling on the underlying EditText. Defaults to `true`. | +| text | `string` | Sets the text value for the element. Note that a getter is not exposed on the TextElement to retrieve the underlying text value. | +| textColor | `reference`|`color` | The text color.

May be a reference to another resource, in the form `"@[+][package:]type/name"` or a theme attribute in the form `"?[package:]type/name"`.

May be a color value, in the form of `"#rgb"`, `"#argb"`, `"#rrggbb"`, or `"#aarrggbb"` | +| textSize | `dimension` | The size of text. | ## CardNumberElement