Search code examples
androidprogress-barseekbar

Android - progressbar or seekbar or?


I need to show values on a horizontal bar like a bar graph. the values are coming from a database. I have a XML layout now showing the value and max and percent. Like this:

10 / 100 10%

But that is pretty boring and doesn't really jump out at the user if they are close to 100%. I have it changing colors of each row now but it would be good to have a sliding "thermometer" showing a graphical representation of the data

the page is only updated when the user click on the button to show the page.

Is there any example on how to use the progress bar or the seek bar or what would you all do? is there examples on how to make whatever you recommend?

thanks!


Solution

  • You could add a ProgressBar

    <ProgressBar
        android:id="@+id/bar"
        android:layout_height="20dip"
        android:layout_width="fill_parent"
        android:indeterminateOnly="false"
        android:progressDrawable="@android:drawable/progress_horizontal"
        android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
        />
    

    And the activity:

    public class ProgressTest extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.progresstest);
            ProgressBar bar = (ProgressBar)findViewById(R.id.bar);
            bar.setProgress(50);
        }
    }