I trying to apply accessibility about talkback on my app.
I want to change the focus to a ImageButton
(custom keypad layout) when the user selects EditText
.
here is my code summary.
edittext.setAccessibilityDelegate(new View.AccessibilityDelegate() {
@Override
public void sendAccessibilityEvent(View host, int eventType) {
if (eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED || eventType == AccessibilityEvent.TYPE_VIEW_CLICKED) {
btn.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
}
});
I set condition about TYPE_VIEW_CLICKED
and TYPE_VIEW_FOCUSED
because when user double tap on the EditText
, a state can be already focused.
but, if eventType is TYPE_VIEW_CLICKED
, the button not only accessibility focus but also cause button click event.
I want to set just focus.
How can I solve this problem?