android - How to set the Rating bar is non clickable and touchable in HTC mobile

前端 未结 4 895
野的像风
野的像风 2020-12-23 02:28

My application have rating bars. I want to set the Rating bar is non-click able and no-touchable. For this i added the following code in xml file of each rating

4条回答
  •  忘掉有多难
    2020-12-23 03:31

    Do not set enabled to false as this will dim the control. What you want to do is override the on touch listener like this:

    import android.view.View.OnTouchListener;
    
    RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar);
    ratingBar.setOnTouchListener(new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });
    

    So basically you intercept the touch and do nothing with it

    Also add the following code too to block trackball rollovers

    ratingBar.setFocusable(false);
    

提交回复
热议问题