ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 66 - Associate Android Developer discussion

Report
Export

In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if you are implementing a custom slider bar that allows a user to select a numeric value by pressing the left or right arrows, your custom view should emit an event of type TYPE_VIEW_TEXT_CHANGED whenever the slider value changes. Which one of the following sample codes demonstrates the use of the sendAccessibilityEvent() method to report this event.

A.
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { boolean completed = super.dispatchPopulateAccessibilityEvent(event); CharSequence text = getText(); if (!TextUtils.isEmpty(text)) { event.getText().add(text); return true;}return completed;}
Answers
A.
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { boolean completed = super.dispatchPopulateAccessibilityEvent(event); CharSequence text = getText(); if (!TextUtils.isEmpty(text)) { event.getText().add(text); return true;}return completed;}
B.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED); return true;}
Answers
B.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED); return true;}
C.
.}
Answers
C.
.}
D.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED); return true;}
Answers
D.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED); return true;}
E.
.}
Answers
E.
.}
Suggested answer: B

Explanation:

Reference:

https://developer.android.com/guide/topics/ui/accessibility/custom-views

asked 18/09/2024
Marcin Piotrowski
40 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first