How to change seekbar progress by 1000 from 10k to 20L?

杀马特。学长 韩版系。学妹 提交于 2020-01-06 08:13:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!