问题
I would like to change the progress value by 1000 for each increment from min 10000 and max 2L value for the seekbar.
Here is the java code for the seekbar:
seekbar.incrementProgressBy(1000);
seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
spinnervalue=(EditText)findViewById(R.id.editText1);
spinnervalue.setText("$"+""+(progress+10000));
}
});
Here seekbar incrementing by progress value and minimum value 10k is setting dynamically.
And here is the layout for seekbar used
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="1990000"/>
Please help by any suggestions basically it is incrementing 11880 i.e., (21880-10000) here 10000 is min value for the seekbar
回答1:
try this
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="200"/>
seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
spinnervalue=(EditText)findViewById(R.id.editText1);
spinnervalue.setText("$"+""+(progress*1000));
}
});
if you dont need zero then modify as follows
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="190"/>
int mProgress =10000;
seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
mProgress = progress*1000+10000;
spinnervalue=(EditText)findViewById(R.id.editText1);
spinnervalue.setText("$"+""+mProgress);
}
});
and use mProgress every where else in program.
来源:https://stackoverflow.com/questions/14950415/how-to-change-seekbar-progress-by-1000-from-10k-to-20l