Posts

Showing posts from September, 2012

Android : How to change progress bar color at runtime programmatically?

Image
I faced this problem while creating one of my android applications(in fact, it is my first application :) ). Lets consider we want to create an android application to calculate the commitments progress of a certain category for http://area51.stackexchange.com/  website ( note we will display a progress bar with one color red or green for simplicity ). Each time we run this application it calculate the commitment percentage and display a red progress bar if it is less than 50% or green one if it equal or greater than 50%. For learning purpose we will insert the number of total required committed users and the number of committed users and calculate the progress of commitment process. Now lets write our code. If it is your first android application you can refer to this post to know how to create an android application.        How to create the full layout of this simple application is beyond this post, we will concentrate on the progress bar. The following code snippet is the