Java Code Examples for android.widget.TextView.announceForAccessibility()

The following are Jave code examples for showing how to use announceForAccessibility() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: iosched-reader   File: MyScheduleActivity.java   View Source Code Vote up 6 votes
private void setTabLayoutContentDescriptions() {
    LayoutInflater inflater = getLayoutInflater();
    int gap = mDayZeroAdapter == null ? 0 : 1;
    for (int i = 0, count = mTabLayout.getTabCount(); i < count; i++) {
        TabLayout.Tab tab = mTabLayout.getTabAt(i);
        TextView view = (TextView) inflater.inflate(R.layout.tab_my_schedule, mTabLayout, false);
        view.setId(baseTabViewId + i);
        view.setText(tab.getText());
        if (i == 0) {
            view.setContentDescription(
                    getString(R.string.talkback_selected,
                            getString(R.string.a11y_button, tab.getText())));
        } else {
            view.setContentDescription(
                    getString(R.string.a11y_button, tab.getText()));
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.announceForAccessibility(
                    getString(R.string.my_schedule_tab_desc_a11y, getDayName(i - gap)));
        }
        tab.setCustomView(view);
    }
}