Java Code Examples for android.widget.RatingBar.setImportantForAccessibility()

The following are Jave code examples for showing how to use setImportantForAccessibility() of the android.widget.RatingBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: iosched-reader   File: SessionFeedbackFragment.java   Source Code and License Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.session_feedback_frag, container, false);

    mTitle = (TextView) rootView.findViewById(R.id.feedback_header_session_title);
    mSpeakers = (TextView) rootView.findViewById(R.id.feedback_header_session_speakers);
    mOverallFeedbackBar = (RatingBar) rootView.findViewById(R.id.rating_bar_0);
    mSessionRelevantFeedbackBar = (NumberRatingBar) rootView.findViewById(
            R.id.session_relevant_feedback_bar);
    mContentFeedbackBar = (NumberRatingBar) rootView.findViewById(R.id.content_feedback_bar);
    mSpeakerFeedbackBar = (NumberRatingBar) rootView.findViewById(R.id.speaker_feedback_bar);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // Helps accessibility services determine the importance of this view.
        mOverallFeedbackBar.setImportantForAccessibility(RatingBar.IMPORTANT_FOR_ACCESSIBILITY_YES);

        // Automatically notifies the user about changes to the view's content description.
        mOverallFeedbackBar.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE);
    }

    // When the rating changes, update the content description. In TalkBack mode, this
    // informs the user about the selected rating.
    mOverallFeedbackBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            ratingBar.setContentDescription(
                    getString(R.string.updated_session_feedback_rating_bar_content_description, (int) rating));
        }
    });

    rootView.findViewById(R.id.submit_feedback_button).setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    submitFeedback();
                }
            }
    );
    return rootView;
}