2

I need to make an energy bar in android for a game- it represents fuel consumption. I am doing this in eclipse.

I have tried using the progress bar in the palette but I cant seem to understand how I would make the bar essentially start at 100% and decrease at equal intervals (every second).

Is is possible using the palette, or should I look for another way.

Any advice is appreciated.

Thanks

N West
  • 6,768
  • 25
  • 40

1 Answers1

0

I know this is old, but one way I've seen it done was by IF commands. Have your Fuel timer "let's say 30 sec Max" set as a variable. and you if commands to update the bar as time ticks away.

   if (fuelTimer == 30) {
            return 100;
        } else if (fuelTimer == 29) {
            return 97;
        } else if (fuelTimer == 28) {
            return 94;
        } else if (fuelTimer == 27) {
            return 91;
        } else if (fuelTimer == 26) {
            return 88;
        } else if (fuelTimer == 25) {
            return 85;
        } else if (fuelTimer == 24) {
            return 82;
        }

Ect... Ect...