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

橙三吉。 提交于 2019-11-28 15:42:42

问题


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 bar.

It is working in samsung galaxy Apollo GT-i5801. But it is not working in the HTC mobile. Why?

xml code

android:clickable="false"     
android:focusableInTouchMode="false"    
android:focusable="false"

thanks


回答1:


You could also set the RatingBar as indicator from the xml with the following:

android:isIndicator="true"



回答2:


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);



回答3:


This is it write this code in your setOnRatingBarChangeListener

ratingaddrate.setIsIndicator(true);

Update :

You can use this example in your XML

android:isIndicator="true"

also add this line to the Code

ratingBar.setFocusable(false);


来源:https://stackoverflow.com/questions/7146976/android-how-to-set-the-rating-bar-is-non-clickable-and-touchable-in-htc-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!