2

I would like to know if I can make changes to colors once the text view has been selected when it has been clicked or touched. There are multiple text view's in the file and I would like to know what I need to do when a certain text view is selected. At the moment I can only change the colour of the

here is my code?

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_image);

    ImageView image = (ImageView) findViewById(R.id.imageView1);
    SeekBar sliderBar = (SeekBar) findViewById(R.id.sliderBar);

    paint = new Paint();
    paint.setColor(Color.RED);

    sliderBar.setProgress(-3);
    sliderBar.incrementProgressBy(1);
    sliderBar.setMax(6);

    category1 = (TextView) findViewById(R.id.category1);
    category2 = (TextView) findViewById(R.id.category2);
    category3 = (TextView) findViewById(R.id.category3);
    category4 = (TextView) findViewById(R.id.category4);
    category5 = (TextView) findViewById(R.id.category5);
    category6 = (TextView) findViewById(R.id.category6);
    category7 = (TextView) findViewById(R.id.category7);
    category8 = (TextView) findViewById(R.id.category8);
    category9 = (TextView) findViewById(R.id.category9);
    textProgress = (TextView) findViewById(R.id.sliderText);

    category1.setClickable(true);
    category2.setClickable(true);
    category3.setClickable(true);
    category4.setClickable(true);
    category5.setClickable(true);
    category6.setClickable(true);
    category7.setClickable(true);
    category8.setClickable(true);
    category9.setClickable(true);
    sliderBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
    {

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) 
        {

            // TODO Auto-generated method stub

            textProgress.setText("The value is: "+ (-3+progress) );

            if(progress ==0) //slider is at -3
            {
                if(category1.isSelected())
                {
                category1.setTextColor(Color.BLUE);
                }
                if(category2.isSelected())
                {
                category2.setTextColor(Color.BLUE);
                }

            }


            else if(progress==1) //slider is at -2
            {
                category1.setTextColor(Color.BLACK);
            }

            else if(progress==2) //slider is at -1
            {
                category1.setTextColor(Color.BLUE);

            }

            else if (progress==3) //slider is at 0
            {
                category1.setTextColor(Color.BLACK);

            }

            else if (progress==4) //slider is at 1
            {
                category1.setTextColor(Color.DKGRAY);
            }

            else if (progress==5) //slider is at 2
            {
                category1.setTextColor(Color.MAGENTA);

            }

            else if (progress==6) //slider is at 3
            {
                category1.setTextColor(Color.RED);
            }

        }

        public void onStartTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub

        }

        public void onStopTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub

        }

    }); 

}

I would like to know when I select a different category, I can change the colour of the text using the seekbar, but only the colour of the textview (category"X") chosen. Thanks.

Biren Jani
  • 21
  • 1
  • possible duplicate of http://stackoverflow.com/questions/4602902/how-to-set-text-color-of-textview-in-code is this what you are looking for ? – Anish Jan 22 '13 at 17:32
  • No unfortunately not. I'm looking for how to select a textview when it is clicked on. And when that textview is selected, you can use the slider to change the colour of the text. I have only managed no to change the first textview but can't find out a way to select a different one and change the colour to that textview. – Biren Jani Jan 22 '13 at 22:10

0 Answers0