Discrete seekbar in Android app?

后端 未结 7 1701
感动是毒
感动是毒 2020-12-29 04:46

I would like to create a seekbar for an Android app that allows the user to select a value between -5 and 5 (which maps to \"strongly disagree\" and \"strongly agree\"). How

7条回答
  •  伪装坚强ぢ
    2020-12-29 05:02

    I don't know what is the issue here, you add a seekbar having a range of 0-10. Then you can map these values to -5 if you substract -5 from the selected value.

    EDIT

    add android:max="10" to the xml definiton and you get a fixed size seekbar.

    You maybe should consider to add a textview to denote the current selected value's textual representation such as: Strongly Disagree. To update this view, subscribe to onProgressChanged event and progress parameter will give you the chosen number.

    SeekBar s = (SeekBar) findViewById(R.id.SeekBar);
    s.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
    
                        @Override
                        public void onProgressChanged(SeekBar seekBar,
                                int progress, boolean fromUser) {
                                        }
    }
    

提交回复
热议问题