Currently I am using the following code :
await Task.Delay(TimeSpan.FromSeconds(1)); view.SendAccessibilityEvent(Android.Views.Accessibility.EventTypes.ViewFocused);
But is this a good practice because I am adding delay in the system.
您可以像下面的onActivityCreated方法中的视图一样执行可访问性操作
view.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
You can use this if your fragment/activity have indivual view:
<view_id>.requestFocus()
<view_id>.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
if you have RecyclerView and you want to focus at the topmost item :
<recyclerView_id>.post {
val child = this.getChildAt(0)
child?.let {
it.requestFocus()
it.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.