1

I'm generating TextViews on LinearLayout programmatically and I want to display the programmatically generated TextViews with Holo effects while on touch on the LinearLayout

for (int i = 1; i <= 10; i++)  {
  LinearLayout linLayout= (LinearLayout) findViewById(R.id.sideIndex);
  TextView tv = new TextView(this);
  tv.setTextColor(getResources().getColor(R.color.white));
// tmpTV.setTypeface(font);
  tv.setText(tmpLetter);
  tv.setGravity(Gravity.CENTER);
  tv.setTextSize(11); 
  tv.setTextColor(getResources().getColor(R.color.holo_green_light));

 LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
 LayoutParams.WRAP_CONTENT,2);

 tv.setLayoutParams(params);

 linLayout.addView(tv);
}

I'm able to view the Holo TextViews with this

tv.setTextColor(getResources().getColor(R.color.holo_green_light));

But I want to view the holo effect on TextView after ontouch on the LinearLayout.

below code working fine for a single instance of programmatically generated TextView but I need to display more than one number of text view in Holo after user touch the LinearLayout!

  linLayout.setOnTouchListener(new OnTouchListener()
    {
        public boolean onTouch(View v, MotionEvent event)
        {
           tv.setTextColor(getResources().getColor(R.color.holo_blue_bright));
            return false;
        }
    });
Cœur
  • 37,241
  • 25
  • 195
  • 267
LOG_TAG
  • 19,894
  • 12
  • 72
  • 105
  • Isn't the theme declaration for the activity just enough? Aren't all the widgets inheriting all the theme attributes? – Robert Estivill Dec 14 '12 at 15:15
  • @RobertEstivill updated the question! I have problem with pragmatically generated stuff! theme declaration I have done!..but no effect on TextView! – LOG_TAG Dec 15 '12 at 09:09

1 Answers1

1

I guess you should set the holo background selector, so your textview responds to the select/pressed/onfocus states. Don't know exactly where the selector is in the holo theme or how it's named, but that should be it.

Robert Estivill
  • 12,369
  • 8
  • 43
  • 64