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:   Source Code and License Vote up 4 votes
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

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

    mTitle = (TextView) rootView.findViewById(;
    mSpeakers = (TextView) rootView.findViewById(;
    mOverallFeedbackBar = (RatingBar) rootView.findViewById(;
    mSessionRelevantFeedbackBar = (NumberRatingBar) rootView.findViewById(
    mContentFeedbackBar = (NumberRatingBar) rootView.findViewById(;
    mSpeakerFeedbackBar = (NumberRatingBar) rootView.findViewById(;

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

        // Automatically notifies the user about changes to the view's content description.

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

            new View.OnClickListener() {
                public void onClick(View view) {
    return rootView;