ExpirationDateTextField
A PCI-compliant XML view component for entering card expiration dates.
This component provides a secure input field for card expiration dates with automatic formatting and validation. It supports both short (MM/YY) and long (MM/YYYY) date formats, with real-time feedback through events for validation and input state changes.
Features:
PCI-compliant input handling
Automatic date formatting
Support for short and long date formats
Real-time validation
Customizable appearance
Example XML usage:
<com.mercadopago.sdk.android.coremethods.ui.components.textfield.expirationdate.xml.ExpirationDateTextField
android:id="@+id/expirationDateField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:readOnly="false"
app:cursorColor="@color/primary" />
Example Kotlin usage:
val expirationDateField = findViewById<ExpirationDateTextField>(R.id.expirationDateField)
// Configure the field
expirationDateField.dateFormat = ExpirationDateFormat.ShortFormat
expirationDateField.textStyle = TextStyle(
color = Color.Black,
fontSize = 16.sp
)
// Handle events
expirationDateField.onEvent = { event ->
when (event) {
is ExpirationDateTextFieldEvent.IsValid -> {
if (event.isValid) {
// Enable next step
}
}
is ExpirationDateTextFieldEvent.OnInputFilled -> {
if (event.isFilled) {
// Handle complete input
}
}
}
}
Parameters
The context in which the view is running
The attributes of the XML tag that is inflating the view
The default style to apply to this view
Properties
Brush applied to customize the text cursor appearance. Default is unspecified color.
The format to use for the expiration date input. This determines the input length and display format:
Configuration for the software keyboard. Use this to customize keyboard behavior and appearance.
Callback triggered for field events (focus changes, input completion, validation). Use this to handle user interactions and update the UI accordingly.
The state holder that manages the expiration date input value and PCI compliance. This state is automatically initialized when the view is created and persists across configuration changes.