**Last updated**: 30 October 2025 | [**Change log**](/access/products/checkout/android/changelog/)

# AccessCheckoutEditText

Important
`AccessCheckoutEditText` is an Android UI component that wraps an `EditText` for the purpose of entering card
details. 

To ensure you remain SAQ-A compliant, we have designed the `AccessCheckoutEditText` component to not
publish any methods or properties that expose the text entered by the end user.

# Customization

You can customize your views using the following properties and methods supported by `AccessCheckoutEditText`.

## XML properties

In addition to the XML properties supported by the `View` class, here are the properties supported by
`AccessCheckoutEditText`:

| Properties | Type |
|  --- | --- |
| android:autofillHints | String |
| android:background | Reference or Color |
| android:cursorVisible | Boolean |
| android:enabled | Boolean |
| android:font | Typeface |
| android:hint | String |
| android:imeOptions | Int |
| android:nextFocusDown | Reference |
| android:nextFocusForward | Reference |
| android:nextFocusLeft | Reference |
| android:nextFocusRight | Reference |
| android:nextFocusUp | Reference |
| android:padding | Dimension |
| android:paddingBottom | Dimension |
| android:paddingEnd | Dimension |
| android:paddingLeft | Dimension |
| android:paddingRight | Dimension |
| android:paddingStart | Dimension |
| android:paddingTop | Dimension |
| android:textColor | Color |
| android:textColorHint | Color |
| android:textSize | Float |


## Methods

In addition to the methods supported by the `View` class, here are the methods supported by `AccessCheckoutEditText`:

| Methods |
|  --- |
| getHint():CharSequence |
| setHint(value:CharSequence) |
| isEnabled():Boolean |
| setEnabled(value:Boolean) |
| getCurrentTextColor():Int |
| setTextColor(value:Int) |
| getCurrentHintTextColor():Int |
| setHintColor(value:Int) |
| getImeOptions():Int |
| setImeOptions(value:Int) |
| getTextSize():Float |
| setTextSize(value:Float) |
| getTypeface():Typeface |
| setTypeFace(value:Typeface) |
| isCursorVisible():Boolean |
| setCursorVisible(value:Boolean) |
| setText(text:String) |
| setOnFocusChangeListener(event: OnFocusChangeListener) |
| getOnFocusChangeListener(): OnFocusChangeListener |
| setTextAppearance(@StyleRes resId: Int) |
| clear() |
| getNextFocusForwardId() |
| setNextFocusForwardId(nextFocusForwardId: Int) |
| getNextFocusUpId() |
| setNextFocusUpId(nextFocusUpId: Int) |
| getNextFocusDownId() |
| setNextFocusDownId(nextFocusDownId: Int) |
| getNextFocusLeftId() |
| setNextFocusLeftId(nextFocusLeftId: Int) |
| getNextFocusRightId() |
| setNextFocusRightId(nextFocusRightId: Int) |
| requestFocus(direction: Int, previouslyFocusedRect: Rect?) |
| focusSearch(direction: Int) |


### Methods supported from higher API levels

There are some methods that are only supported by `AccessCheckoutEditText` from specific API levels upwards:

| Methods | API level |
|  --- | --- |
| setAutofillHints(hints: String) | 26 |
| getAutofillHints():Array<String> | 26 |
| setAutoSizeTextTypeWithDefaults(@TextViewCompat.AutoSizeTextType autoSizeTextType: Int) | 26 |


### Methods not supported

Below are methods from the `View` class which are not supported:

| Methods not supported |
|  --- |
| getBackgroundTintList():ColorStateList |
| setBackgroundTintMode(PorterDuff.Mode tintMode) |
| setBackgroundTintBlendMode(BlendMode blendMode) |


# Enabling card auto-fill

`AccessCheckoutEditText` is compatible with `android:autofillHints`. Providing `autofillHints` enables the autofill
service to recognize the type of view, making it possible for your customer to enter credit card details automatically
in your
application.

You can set autofill hints using the `android:autofillHints` attribute. The following example sets a "creditCardNumber"
hint on an `AccessCheckoutEditText`:


```xml

<com.worldpay.access.checkout.ui.AccessCheckoutEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        android:autofillHints="creditCardNumber"/>
```

You should assign the appropriate autofill hint to each `AccessCheckoutEditText` input field based on its purpose.
Use:

- `creditCardNumber` for the card number field
- `creditCardExpirationDate` for the expiry date
- `creditCardSecurityCode` for the credit card security code (CVC/CVV)


You can also set hints programmatically using the setAutofillHints() method, as shown in the following example:


```kotlin
val creditCardNumber = findViewById<EditAccessCheckoutEditTextText>(R.id.credit_card_number)
creditCardNumber.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_NUMBER)
```

# Handling onFocus events

`AccessCheckoutEditText` has support for `onFocus` events, allowing your application to update the UI dynamically when
your customer interacts with the `AccessCheckoutEditText`.

You must use the `setOnFocusChangeListener` method to react to focus changes.

The example below changes the background of the `AccessCheckoutEditText` when the field gains focus to the secondary
color and changes it back to the primary color when the field loses focus.


```kotlin
val panText = view.findViewById(R.id.credit_card_number)
panText.setOnFocusChangeListener { view, hasFocus ->
    val color = if (hasFocus) R.color.design_default_color_secondary else R.color.design_default_color_on_primary
    view.setBackgroundColor(ContextCompat.getColor(requireContext(), color))
}
```

# Use Espresso for UI testing

`AccessCheckoutEditText` acts as a wrapper around an `EditText`. This is to ensure you can't access the `EditText`
instance and remain SAQ-A compliant.

Because of this, you must perform an action on the `EditText` rather than on the `AccessCheckoutEditText` instance.

You can access the `EditText` instance in Espresso by using the code below, where the id corresponds to the id of the
`AccessCheckoutEditText` instance:


```kotlin
Espresso.onView(ViewMatchers.withParent(withId(R.id.your_identifier)))
```