how to change colours in a .xml defined layout in run time

by ckloch » Wed, 16 Jun 2010 20:05:26 GMT

Sponsored Links
 Dear friends,

I am developing a small app that should inform the drivers whether his
current speed matches the preferred one in order to avoid stopping for
the red light.

I have no probelms to calculate the relative speed of the vehicle and
compare it with the preferred speed in order to determine and inform
the driver whether his speed is appropriate for crossing the traffic
light when it is green, or he needs to slow down or speed up.

But, I would be very thankful if you can help me to display this

My current idea is to draw a traffic light (in red and green) on the
screen in .xml, using 11 equally sized bars. Hereby, I can show
whether the speed fits perfectly (then bar 6 should be black), or
there is no room for delay (then bar 4 should be black)
So far, I have made the traffic light in .xml.

My next step is to change the color of one of the bars dependent on
how the relative speed matches the shifts in the traffic light.
In theory it seems to be easy, but I would highly appreciate your help
on how to do this in Android as I cannot see how I start changing the
colours of the individual bar in the screen after initially defining
the screen.

There might be other and better ways to implement this than .xml

I would appreciate your help;

Best regards


Other Threads

1. accept incoming file request programmatically

Dear All:

When a file is sent to an android phone via Bluetooth, we have to
manually accept the incoming file request. How can we accept it
programmatically without user interaction? Thanks in advance.


2. ActivityGroups in Tab Problem

Hi everyone;

I have 3 tabs in activity group.
In Each tab(Separate Activity group) there are around 4 activities and
I'm switching between the activities without any problem.
My problem is with the device Emulator device back button.
while i am in an sub-activity (for ex. 2nd activity) if i push back
button, the application is finished. I override backKeyPress() method
to start previus sub-activity.

Method code:

                public boolean onKeyDown(int keyCode, KeyEvent event) {
                        if (keyCode == KeyEvent.KEYCODE_BACK) {
                        Intent intent = new Intent(Activity3.this, 
                    return true;
                return super.onKeyDown(keyCode, event);
i am sorry, mey english's not enough.

Please help me! I have not solved this problem for 3 weeks.



3. Honeycomb Preview SDK: HTTP Live Streaming support validation

4. Lodsys Threatens to Sue App Store Developers Over In-App Purchases and Upgrade Links

5. NFC send Url p2p

6. ISO 15693 UID inversed

7. Android init.rc