Reputation: 131
I want Fragment
to announce itself on launch in Android Talkback. Activity
does announce itself when added 'android:label' on the activity tag in AndroidManifest file. How can I do that for Fragment
?
Upvotes: 9
Views: 5539
Reputation: 33
I was having trouble with the same and the accepted answer did not work for me. I had a look at the lifecycle of a fragment and decided to call it on the last method before the fragment became active: onResume
@Override
public void onResume() {
super.onResume();
rootView.announceForAccessibility("title of my fragment");
}
Upvotes: 2
Reputation: 15334
You can use one of the Fragment lifecycle methods to announce it yourself.
Fragments don't have an intrinsic title, and since they're basically Views + logic, it seems reasonable that the system can't predict when it would be appropriate to announce a newly added Fragment.
Something like overriding onCreateView(View view, ...)
and then calling view.announceForAccessibility("title of my fragment")
would work.
Upvotes: 11