Changing the TextView color depending on the progress of a SeekBar

witiebyin

New Member
I am trying to change the color of the \[code\]TextView\[/code\] depending on the \[code\]SeekBar\[/code\]'s progress as following:
  • 0-25% -> green
  • 25%-50% -> yellow and so on...
When I using the following code, the \[code\]TextView\[/code\] doesn't show the value anymore.I would greatly appreciate any help! Code:\[code\]public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { textView.setText(String.valueOf(progress + "%")); if(progress >= 25 && progress < 50) textView.setTextColor(R.color.Yellow); else if(progress >= 50 && progress < 75) textView.setTextColor(R.color.Orange); else if(progress >= 75 && progress <= 100) textView.setTextColor(R.color.Red); else textView.setTextColor(R.color.Green);} \[/code\]XML:\[code\]<TextView android:id="@+id/eT" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/tvProgress" android:textColor="@color/Green" android:textSize="25dp" android:textStyle="bold" android:layout_gravity="center" android:layout_marginBottom="5dp" />\[/code\]
 
Back
Top