views:

142

answers:

2

Hi,

I am somewhat of a new android developer and have a question regarding changing the background dynamically at runtime.

What I want to do is set a background color in a LinearLayout Tag, and later change that background color in my activity class. This code below is not working. Am I missing something or is this the wrong approach for trying to change the background color in a linear layout

LinearLayout lv = (LinearLayout)findViewById(R.id.ChoiceLayout);
lv.setBackgroundColor(0x000080);

Thanks in advance

A: 

AFAIK, that should work fine. Use hierarchyviewer to try to diagnose what is going wrong.

CommonsWare
+1  A: 

First thing I've noticed is that your color has ALPHA = 0x00. Which makes it transparent. Try changing to

lv.setBackgroundColor(0xFF000080);
Paul Turchenko
That was it. Thanks a bunch!
Kevin