VGSEditText
Provides a user interface element that displays text.
Validation
Default behavior validates any user content. There are several ways to customize basic validation flow:
XML attributes:
app:enableValidation
;Validation builder.
Determining validation rules
val postalCode = findViewById(R.id.postalCode)
val rule : VGSInfoRule = VGSInfoRule.ValidationBuilder()
.setRegex("<VALIDATION_REGEX>")
.setAllowableMinLength(1)
.setAllowableMaxLength(8)
.build()
postalCode.setRule(rule)
Set field name
Sets the text to be used for data transfer to VGS proxy. Usually, it is similar to field-name in JSON path in your inbound route filters. It is highly important to specify this parameter because the VGSCollect module relies on it too.
Warning: You must set up fieldName
in other way input field will be ignored by VGSCollect.
<com.verygoodsecurity.vgscollect.widget.VGSEditText
android:id="@+id/infoField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:fieldName="info_field_name>"/>
Define the required state
Specifies whether the text inside input field is required to be filled.
When app:isRequired
set as true
, then input data should be valid only. If app:isRequired
set as false
, then input data will be valid in case the field is empty. Otherwise input data should be valid.
By default, widget is required.
<com.verygoodsecurity.vgscollect.widget.VGSEditText
android:id="@+id/infoField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:isRequired="false"/>
Specify the keyboard type
You should always declare the input method for this input fields by adding the app:inputType
to tell the system displays the appropriate soft input method (such as an on-screen keyboard).
For example, if you'd like an input method for entering a phone number specify app:inputType
as number
or numberPassword
<com.verygoodsecurity.vgscollect.widget.VGSEditText
android:id="@+id/infoField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:inputType="number"/>
Supported input types:
none - there is no content type.
text - for normal text.
textPassword - for text that is a password.
number - for numeric only text.
numberPassword - for numeric password text.
date - for entering a date.
textCapCharacters - capitalize all characters.
textCapWords - capitalize the first character of every word.
Additional XML attributes
Attribute
Description
app:inputType
Set the type of the content with a constant as defined for input field.
app:imeOptions
Specify soft input method for the input method action. By default, the system uses a
actionNext
Plain textor
actionDone
Plain textaction.
app:fontFamily
Default font family (named by string or as a font resource reference) for the text.
app:fieldName
Sets the text to be used for data transfer to VGS proxy. Usually, it is similar to field-name in JSON path in your inbound route filters.
app:isRequired
Specifies whether the text inside input field is required to be filled.
app:textSize
Size of the text.
app:ellipsize
If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle.
app:ellipsize
If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle.
app:text
Text to display.
app:textColor
Text color.
app:maxLines
Makes the View be at most this many lines tall.
app:minLines
Makes the View be at least this many lines tall.
app:textStyle
Style (normal, bold, italic) for text.
app:cursorVisible
Makes the cursor visible (the default) or invisible.
app:gravity
Specifies how to align the text by the view’s x- or y-axis when the text is smaller than the view.
app:scrollHorizontally
When the text is allowed to be wider than the view (and therefore can be scrolled horizontally).
app:hint
Hint text to display when the text is empty.
Last updated