Udostępnij za pośrednictwem


View.DispatchCreateViewTranslationRequest Method

Definition

Dispatch to collect the ViewTranslationRequests for translation purpose by traversing the hierarchy when the app requests ui translation.

[Android.Runtime.Register("dispatchCreateViewTranslationRequest", "(Ljava/util/Map;[ILandroid/view/translation/TranslationCapability;Ljava/util/List;)V", "GetDispatchCreateViewTranslationRequest_Ljava_util_Map_arrayILandroid_view_translation_TranslationCapability_Ljava_util_List_Handler", ApiSince=31)]
public virtual void DispatchCreateViewTranslationRequest (System.Collections.Generic.IDictionary<Android.Views.Autofill.AutofillId,long[]> viewIds, int[] supportedFormats, Android.Views.Translation.TranslationCapability capability, System.Collections.Generic.IList<Android.Views.Translation.ViewTranslationRequest> requests);
[<Android.Runtime.Register("dispatchCreateViewTranslationRequest", "(Ljava/util/Map;[ILandroid/view/translation/TranslationCapability;Ljava/util/List;)V", "GetDispatchCreateViewTranslationRequest_Ljava_util_Map_arrayILandroid_view_translation_TranslationCapability_Ljava_util_List_Handler", ApiSince=31)>]
abstract member DispatchCreateViewTranslationRequest : System.Collections.Generic.IDictionary<Android.Views.Autofill.AutofillId, int64[]> * int[] * Android.Views.Translation.TranslationCapability * System.Collections.Generic.IList<Android.Views.Translation.ViewTranslationRequest> -> unit
override this.DispatchCreateViewTranslationRequest : System.Collections.Generic.IDictionary<Android.Views.Autofill.AutofillId, int64[]> * int[] * Android.Views.Translation.TranslationCapability * System.Collections.Generic.IList<Android.Views.Translation.ViewTranslationRequest> -> unit

Parameters

viewIds
IDictionary<AutofillId,Int64[]>

a map for the view's AutofillId and its virtual child ids or null if the view doesn't have virtual child that should be translated. The virtual child ids are the same virtual ids provided by ContentCapture.

supportedFormats
Int32[]

the supported translation formats. For now, the only possible value is the android.view.translation.TranslationSpec#DATA_FORMAT_TEXT.

capability
TranslationCapability

a TranslationCapability that holds translation capability. information, e.g. source spec, target spec.

requests
IList<ViewTranslationRequest>

fill in with ViewTranslationRequests for translation purpose.

Attributes

Remarks

Dispatch to collect the ViewTranslationRequests for translation purpose by traversing the hierarchy when the app requests ui translation. Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup). Other classes should override View#onCreateViewTranslationRequest for normal view or override View#onVirtualViewTranslationResponses for view contains virtual children. When requested to start the ui translation, the system will call this method to traverse the view hierarchy to collect ViewTranslationRequests and create a android.view.translation.Translator to translate the requests. All the ViewTranslationRequests must be added when the traversal is done.

The default implementation calls View#onCreateViewTranslationRequest for normal view or calls View#onVirtualViewTranslationResponses for view contains virtual children to build ViewTranslationRequest if the view should be translated. The view is marked as having #setHasTransientState(boolean) transient state so that recycling of views doesn't prevent the system from attaching the response to it. Therefore, if overriding this method, you should set or reset the transient state.

Java documentation for android.view.View.dispatchCreateViewTranslationRequest(java.util.Map<android.view.autofill.AutofillId, long[]>, int[], android.view.translation.TranslationCapability, java.util.List<android.view.translation.ViewTranslationRequest>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to