2

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!

Mark Worsnop
  • 4,407
  • 15
  • 54
  • 79
  • I'm not really sure what you are asking for here. If you just want to add the text '10/100' somewhere on the screen at a `TextView` and us an OnSeekBarChangedListener` to update the textview with the new value. – Nathan Schwermann Feb 18 '11 at 21:36

1 Answers1

1

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);
    }
}
Arve
  • 8,058
  • 2
  • 22
  • 25
  • this is exactly what I was looking for! thanks! is there a way to add text to the bar? also is there a way to set the color of the bar from the app (not the xml)? – Mark Worsnop Feb 18 '11 at 22:29
  • Adding text and changing color is described [here](http://colintmiller.com/2010/10/07/how-to-add-text-over-a-progress-bar-on-android/) :-) – Arve Feb 18 '11 at 22:37