public interface

GuidedActionAutofillSupport

 androidx.leanback.widget.GuidedActionAutofillSupport

Subclasses:

GuidedActionAppCompatEditText, GuidedActionEditText

Gradle dependencies

compile group: 'androidx.leanback', name: 'leanback', version: '1.2.0-alpha04'

  • groupId: androidx.leanback
  • artifactId: leanback
  • version: 1.2.0-alpha04

Artifact androidx.leanback:leanback:1.2.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.leanback:leanback com.android.support:leanback-v17

Androidx class mapping:

androidx.leanback.widget.GuidedActionAutofillSupport android.support.v17.leanback.widget.GuidedActionAutofillSupport

Overview

Interface for a custom EditText subclass to support autofill in GuidedStepSupportFragment.

Apps who needs to supply custom layouts for GuidedActionsStylist with their own EditText classes should implement this interface in order to support autofill in GuidedStepSupportFragment. This ensures autofill event happened within custom EditText is propagated to GuidedStepSupportFragment. e.g.


 public class MyEditText extends EditText implements GuidedActionAutofillSupport {
     OnAutofillListener mAutofillViewListener;
     @Override
     public void setOnAutofillListener(OnAutofillListener autofillViewListener) {
         mAutofillViewListener = autofillViewListener;
     }

     @Override
     public void autofill(AutofillValue values) {
         super.autofill(values);
         if (mAutofillViewListener != null) {
             mAutofillViewListener.onAutofill(this);
         }
     }
     // ...
 }
 

Summary

Methods
public voidsetOnAutofillListener(GuidedActionAutofillSupport.OnAutofillListener listener)

Sets AutofillListener on the custom view.

Methods

public void setOnAutofillListener(GuidedActionAutofillSupport.OnAutofillListener listener)

Sets AutofillListener on the custom view.

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.leanback.widget;

import android.view.View;

/**
 * Interface for a custom EditText subclass to support autofill in
 * {@link androidx.leanback.app.GuidedStepSupportFragment}.
 * <p>
 *
 * Apps who needs to supply custom layouts for {@link GuidedActionsStylist} with their own EditText
 * classes should implement this interface in order to support autofill in
 * {@link androidx.leanback.app.GuidedStepSupportFragment}. This ensures autofill event happened
 * within custom EditText is propagated to GuidedStepSupportFragment.
 * e.g.
 * <pre><code>
 * public class MyEditText extends EditText implements GuidedActionAutofillSupport {
 *     OnAutofillListener mAutofillViewListener;
 *     &#064;Override
 *     public void setOnAutofillListener(OnAutofillListener autofillViewListener) {
 *         mAutofillViewListener = autofillViewListener;
 *     }
 *
 *     &#064;Override
 *     public void autofill(AutofillValue values) {
 *         super.autofill(values);
 *         if (mAutofillViewListener != null) {
 *             mAutofillViewListener.onAutofill(this);
 *         }
 *     }
 *     // ...
 * }
 * </code></pre>
 *
 */
public interface GuidedActionAutofillSupport {

    /**
     * Listener for autofill event. Leanback will set the Listener on the custom view.
     */
    interface OnAutofillListener {

        /**
         * Custom view should call this method when autofill event happened.
         *
         * @param view The view where autofill happened.
         */
        void onAutofill(View view);

    }

    /**
     * Sets AutofillListener on the custom view.
     */
    void setOnAutofillListener(OnAutofillListener listener);
}