问题描述
我有两个seekbars。我想设置第一个搜索栏过程值分配第二个搜索栏的初始值。我的确切的要求是,我想覆盖0〜100三个seekbar.Ex:如果FirstSeekBar覆盖1至30日的第二搜索栏会自动启动30到100。如果我设置过程值60在第二搜索栏的第三个搜索栏会自动启动60至100。请帮我解决这个问题。
activity.xml
<搜索栏
机器人:ID =@ + ID / firstSeekBar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =30dp/>
<搜索栏
机器人:ID =@ + ID / secondSeekBar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp/>
<搜索栏
机器人:ID =@ + ID / thirdSeekBar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp/>
SeekBarActivity.java
firstSeekBar.setOnSeekBarChangeListener(
新SeekBar.OnSeekBarChangeListener(){
INT firstPgrValue;
@覆盖
公共无效onProgressChanged(搜索栏搜索栏,INT进步,布尔FROMUSER){
firstPgrValue =进展情况;
secondSeekBar.setEnabled(真正的);
txtFirstSeek.setText(第一(+进展+/+ firstSeekBar.getMax()+));
}
@覆盖
公共无效onStartTrackingTouch(搜索栏搜索栏){
的ShortMessage(MainActivity.this,进步开始);
}
@覆盖
公共无效onStopTrackingTouch(搜索栏搜索栏){
如果(firstPgrValue == 0){
secondSeekBar.setEnabled(假);
redSeekBar.setEnabled(假);
}
txtFirstSeek.setText(第一(+ firstPgrValue +/+ firstSeekBar.getMax()+));
的ShortMessage(MainActivity.this,进步停止);
}
}
);
secondSeekBar.setOnSeekBarChangeListener(新SeekBar.OnSeekBarChangeListener(){
INT secondPgrValue;
@覆盖
公共无效onProgressChanged(搜索栏搜索栏,INT进步,布尔FROMUSER){
secondPgrValue =进展情况;
thirdSeekBar.setEnabled(真正的);
txtSecondSeek.setText(第二(+进展+/+ secondSeekBar.getMax()+));
}
@覆盖
公共无效onStartTrackingTouch(搜索栏搜索栏){
的ShortMessage(MainActivity.this,进步开始);
}
@覆盖
公共无效onStopTrackingTouch(搜索栏搜索栏){
如果(secondPgrValue == 0){
thirdSeekBar.setEnabled(假);
}
txtSecondSeek.setText(第二(+ secondPgrValue +/+ secondSeekBar.getMax()+));
的ShortMessage(MainActivity.this,进步停止);
}
});
thirdSeekBar.setOnSeekBarChangeListener(新SeekBar.OnSeekBarChangeListener(){
INT thirdPsrValue;
@覆盖
公共无效onProgressChanged(搜索栏搜索栏,INT进步,布尔FROMUSER){
thirdPsrValue =进展情况;
txtRedSeek.setText(第三(+进度+/+ redSeekBar.getMax()+));
}
@覆盖
公共无效onStartTrackingTouch(搜索栏搜索栏){
的ShortMessage(MainActivity.this,进步开始);
}
@覆盖
公共无效onStopTrackingTouch(搜索栏搜索栏){
txtThirdSeek.setText(第三(+ thirdPsrValue +/+ thirdSeekBar.getMax()+));
的ShortMessage(MainActivity.this,进步停止);
}
});
不幸的是香草搜索栏
并没有一个默认的分
字段。我存储在并行该值与凌乱和不方便 INT
字段。你可以扩展类,还是像我一样,但在我看来,你所描述的一个常见的情况,该功能为它已经提供了许多 RangeBar
的实施。
https://github.com/yahoo/android-range-seek-bar 只有两个大拇指,应该是理想的。 其他提供无限的大拇指。
I have two seekbars. I want to set first Seekbar process value is to assign initial value of second Seekbar. My Exact requirement is, I want cover 0 to 100 with three seekbar.Ex : If FirstSeekBar cover 1 to 30 the Second SeekBar automatically starts 30 to 100. if I set process value 60 in second seekbar the Third Seekbar automatically starts 60 to 100. Please help me to solve this problem.
activity.xml
<SeekBar
android:id="@+id/firstSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"/>
<SeekBar
android:id="@+id/secondSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<SeekBar
android:id="@+id/thirdSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
SeekBarActivity.java
firstSeekBar.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
int firstPgrValue;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
firstPgrValue = progress;
secondSeekBar.setEnabled(true);
txtFirstSeek.setText("First (" + progress + " / " + firstSeekBar.getMax() + ")");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
shortMessage(MainActivity.this, "Progress Start");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (firstPgrValue == 0) {
secondSeekBar.setEnabled(false);
redSeekBar.setEnabled(false);
}
txtFirstSeek.setText("First (" + firstPgrValue + " / " + firstSeekBar.getMax() + ")");
shortMessage(MainActivity.this, "Progress Stopped");
}
}
);
secondSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int secondPgrValue;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
secondPgrValue = progress;
thirdSeekBar.setEnabled(true);
txtSecondSeek.setText("Second (" + progress + " / " + secondSeekBar.getMax() + ")");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
shortMessage(MainActivity.this, "Progress Start");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (secondPgrValue == 0) {
thirdSeekBar.setEnabled(false);
}
txtSecondSeek.setText("Second (" + secondPgrValue + " / " + secondSeekBar.getMax() + ")");
shortMessage(MainActivity.this, "Progress Stopped");
}
});
thirdSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int thirdPsrValue;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
thirdPsrValue = progress;
txtRedSeek.setText("Third (" + progress + " / " + redSeekBar.getMax() + ")");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
shortMessage(MainActivity.this, "Progress Start");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
txtThirdSeek.setText("Third (" + thirdPsrValue + " / " + thirdSeekBar.getMax() + ")");
shortMessage(MainActivity.this, "Progress Stopped");
}
});
Unfortunately vanilla SeekBar
does not have a default min
field. I store this value in parallel with untidy and inconvenient int
fields. You could extend the class, or do as I do, but it seems to me you are describing a common situation, the functionality for which is already provided by many RangeBar
implementations.
https://github.com/yahoo/android-range-seek-bar has just two thumbs and should be ideal. Others provide unlimited thumbs.
这篇关于如何设置第一个搜索栏过程值是在Android的配第二搜索栏的初始值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!