问题
I have just like this figure, which is get value from this,

Here I Used SeekBar,but could not get value where i mention in figure. would you guys help me this problem?
So please also provide me information , what is the best solution to get this type of value?
Here all are differenet seek bar.
First SeekBar have 25% and second seek Baar 50%. If i have scroll seek bar then simultaneously increase or decrease the percentage in box.
回答1:
Create a view in xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<SeekBar
android:id="@+id/SeekBarId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="92" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="4dp"
android:layout_weight="8"
android:gravity="center"/>
</LinearLayout>
set onSeekBarChageListener on the seekBar, like this:
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
public void onStopTrackingTouch(SeekBar bar)
{
int value = bar.getProgress(); // the value of the seekBar progress
}
public void onStartTrackingTouch(SeekBar bar)
{
}
public void onProgressChanged(SeekBar bar,
int paramInt, boolean paramBoolean)
{
textView.setText("" + paramInt + "%"); // here in textView the percent will be shown
}
});
回答2:
String[] percent = { "0", "10", "20", "30", "40", "50", ... "100" };
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
baths.setText("" + percent[progress] + "%");
}
});
Add do add in xml-layout in seekbar:-
android:max="10"
来源:https://stackoverflow.com/questions/9821614/getting-percentage-value-from-seek-bar