我想将Seekbar的值增加0.25,这是myLayout.xml:
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="8dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@+id/tvYMax"
android:max="12"
android:paddingBottom="12dp" />
我想输出如:0,0.25,0.50,0.75,1,1.25,1.50,1.75,2 ......
答案 0 :(得分:1)
试试这可能会对你有所帮助
seekbar.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener(){
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
// TODO Auto-generated method stub
Toast.makeText(seekBar.getContext(), "Value: "+(float) progress/4, Toast.LENGTH_SHORT).show();
}
public void onStartTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
});
答案 1 :(得分:0)
答案 2 :(得分:0)
让我们假设你的搜索栏从0到12开始
android:max="48"
android:min="0"
interval = "1"
显示时
@Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
long progressToDisplay = progress/4.0f;
//0 -> 0.00,1 -> 0.25,2 -> 0.50 ..so on ... ,48 -> 12
}