Range-seek-bar的进度值不会更新

时间:2014-03-12 04:10:40

标签: java android

我正在尝试使用两个拇指搜索栏


我正在使用 This - PROJECT


MainActivity.java

public class MainActivity extends Activity {

    protected static final String TAG = null;
    private TextView txtStart,txtEnd;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        txtStart= (TextView) findViewById(R.id.edt_starttime);
        txtEnd= (TextView) findViewById(R.id.edt_endtime);
        // create RangeSeekBar as Integer range between 20 and 75
        RangeSeekBar<Integer> seekBar = new RangeSeekBar<Integer>(100, 1500, this);


        seekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>() {
            @Override
            public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar,
                    Integer minValue, Integer maxValue) {
                  // handle changed range values
                 String powerranger = "User selected new range values: MIN=" + minValue + ", MAX=" + maxValue;
                 //Log.i(TAG, powerranger);
                 //textView1.setText(powerranger);
                 txtStart.setText(String.valueOf(minValue));
                 txtEnd.setText(String.valueOf(maxValue));

            }
        });

        // add RangeSeekBar to pre-defined layout
        ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
        layout.addView(seekBar);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

RangeSeekBar.java 我已经from here

注意::我无法发布完整代码,因为代码超出了网站允许的最大字符 RangeSeekBar.java


输出 ::

enter image description here


我面临的问题 ::

  • 在移动重击期间,它没有使用更新textView 范围值
  • 只有在我们从拇指上移开手后才会更新

1 个答案:

答案 0 :(得分:8)

我快速查看了代码,似乎RangeSeekBar类具有notifyWhileDragging属性,您必须将其设置为true才能获得所需内容(它是{默认情况下为{1}}。