android long 最大值,如何格式化android-range-seek-bar的最小值和最...

叶阳
2023-12-01

我在https://github.com/anothem/android-range-seek-bar使用控件android-range-seek-bar来显示两个拇指控件,允许选择一个范围.

我希望将指示条上选定的最小和最大值的文本格式设置为“ hh:mm:ss”,我创建了一个函数ConvertSecondsToHMmSs,该怎么做?如1000L显示“ 00:00:01”

还有更多,我希望在最小值或最大值发生变化时做一些事情,但是只有事件public void onRangeSeekBarValuesChanged(RangeSeekBar bar,Long minValue,Long maxValue),它无法区分哪个值,最小值或最大值值,已更改.我希望在最小值更改时执行A,在最大值更改时执行B!

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

RangeSeekBar seekBar = (RangeSeekBar) findViewById(R.id.myRangeSeekBar);

seekBar.setRangeValues(1000L,2000L);

}

private String ConvertSecondsToHMmSs(long millis) {

return String.format("%02d:%02d:%02d",

TimeUnit.MILLISECONDS.toHours(millis),

TimeUnit.MILLISECONDS.toMinutes(millis) -

TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),

TimeUnit.MILLISECONDS.toSeconds(millis) -

TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));

}

布局

xmlns:tools="http://schemas.android.com/tools"

xmlns:rsb="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

android:paddingBottom="@dimen/activity_vertical_margin"

tools:context=".MainActivity">

android:layout_height="wrap_content" />

android:id="@+id/myRangeSeekBar"

android:layout_width="match_parent"

android:layout_height="wrap_content"

rsb:absoluteMaxValue="150"

rsb:absoluteMinValue="20"/>

build.gradle

apply plugin: 'com.android.application'

android {

compileSdkVersion 23

buildToolsVersion "23.0.2"

defaultConfig {

applicationId "com.example.cuiwei.myapplication"

minSdkVersion 21

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'

}

 类似资料: