Bummer! You have been redirected as the page you requested could not be found.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Implementing Designs for Android Customizing the Action Bar Adding Icons to Tabs

Alex Feinberg
Alex Feinberg
2,025 Points

Accessibility of tabs with icons

In this video, the tab text is replaced with icons. Nice. It would be even better to replace the text with both icons and content descriptions to improve accessibility. Here is the improved code:

actionBar.addTab(actionBar.newTab()
.setContentDescription(mSectionsPagerAdapter.getPageTitle(i))
.setIcon(mSectionsPagerAdapter.getIcon(i))
.setTabListener(this));

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Excellent! Thanks for sharing. I should have included this. I'll add it as a note on the video page.

Hey guys, I don't understand the goal of that extra line. Could you explain what you mean with improve accessibility?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Adding a content description gives a text description of the image on the icon. This is useful for users who have certain accessibility features enabled, like screen readers. This specifically is helpful for users who have difficulty reading the screen or making out icons.

Sorry for the late reply!