Android搜索栏不显示最小值和最大值

时间:2015-09-03 11:30:59

标签: android

我想动态地将最小值和最大值设置为双手搜索条。我从JSON Response获得了搜索栏的最小值和最大值。但我的搜索栏不显示最小值和最大值。我给双手搜索栏是这样的:

    rangeSeekBar = new RangeSeekBar (seekbar_MinValue, seekbar_MaxValue, getActivity());
    ViewGroup layout = (ViewGroup) view.findViewById(R.id.range_bar_LinearLayout);
    layout.addView(rangeSeekBar);


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

            lsp_minvalue = minValue;
            lsp_maxvalue = maxValue;

            pt_lspMintv.setText(Integer.toString(lsp_minvalue));
            pt_lspMaxtv.setText(Integer.toString(lsp_maxvalue));



        }
    });


    // The problem is, at the time of setSelectedMinValue

       int seekbar_MinValue = 0, seekbar_MaxValue = 0;
                try {


                    seekbar_MinValue = Integer.parseInt(minSeekValue);
                    rangeSeekBar.setSelectedMinValue(seekbar_MinValue);

                    seekbar_MaxValue = Integer.parseInt(maxSeekValue);
                    rangeSeekBar.setSelectedMaxValue(seekbar_MaxValue);


                }catch (NumberFormatException e){
                    e.printStackTrace();

1 个答案:

答案 0 :(得分:0)

不使用setOnRangeSeekBarChangeListener,你必须使用它,

seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
            progressChanged = progress;
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            Toast.makeText(SeekbarActivity.this,"seek bar progress:"+progressChanged, 
                    Toast.LENGTH_SHORT).show();
        }
    });