Skip to content

Commit

Permalink
feat: Documenting Android setValueRef and isEditable properties (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhudec authored Jan 6, 2023
1 parent cc456b0 commit 3bb7667
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions docs/sdks/mobile/android/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
sidebar_label: Types
---

import { Alert } from "@site/src/components/shared/Alert";

# Android Element Types

## TextElement
Expand Down Expand Up @@ -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. |

<Alert>
When using <code>setValueRef</code> to keep a <code>TextElement</code> in sync with another element, it is strongly recommended that
you make the dependent element readonly by also setting <code>isEditable=false</code>.
</Alert>

#### 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`&vert;`color` | The text color. <br/><br/>May be a reference to another resource, in the form `"@[+][package:]type/name"` or a theme attribute in the form `"?[package:]type/name"`. <br/><br/>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`&vert;`color` | The text color. <br/><br/>May be a reference to another resource, in the form `"@[+][package:]type/name"` or a theme attribute in the form `"?[package:]type/name"`. <br/><br/>May be a color value, in the form of `"#rgb"`, `"#argb"`, `"#rrggbb"`, or `"#aarrggbb"` |
| textSize | `dimension` | The size of text. |

## CardNumberElement

Expand Down

1 comment on commit 3bb7667

@vercel
Copy link

@vercel vercel bot commented on 3bb7667 Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.