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

AndroidRatingbar

Android Problem Overview


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

Android Solutions


Solution 1 - Android

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

android:isIndicator="true"

Solution 2 - Android

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

Solution 3 - Android

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

Solution 4 - Android

Add style="?android:attr/ratingBarStyleIndicator" into your layout
For example

<RatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/review_star"
        style="?android:attr/ratingBarStyleIndicator"
        android:scaleX=".5"
        android:rating="3.5"
        android:scaleY=".5"
        android:transformPivotX="0dp"
        android:transformPivotY="0dp"
        android:max="5"/>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnareshView Question on Stackoverflow
Solution 1 - AndroidAndyView Answer on Stackoverflow
Solution 2 - Androidalireza aminiView Answer on Stackoverflow
Solution 3 - AndroidRyan CView Answer on Stackoverflow
Solution 4 - AndroidInfomasterView Answer on Stackoverflow