Android SeekBarPreference

后端 未结 3 932
独厮守ぢ
独厮守ぢ 2020-12-06 18:49

I\'m currently trying to implement SeekBarPreference class using http://android-journey.blogspot.com/2010/01/for-almost-any-application-we-need-to.html tutorial with Relativ

相关标签:
3条回答
  • 2020-12-06 19:29

    The problem with sliding here is due to notifyChange() call. That is interfering with the sliding somehow. I am also working on similar widget because I do not like the Dialog approach.

    As promised here is the solution that I added to my open source project:

    I have written a SeekBarPreference class that is embeded widget inside the preferences activity instead of popup dialog. You can download the jar file from:

    http://aniqroid.sileria.com/

    The class documentation and usage is here: http://aniqroid.sileria.com/doc/api/com/sileria/android/view/SeekBarPreference.html

    Also do not forget to checkout the handy companion class to auto show a summary when you change the SeekBar: http://aniqroid.sileria.com/doc/api/com/sileria/android/event/PrefsSeekBarListener.html

    0 讨论(0)
  • 2020-12-06 19:30

    Slider works in tutorial by changing onProgressChanged to

    public void onProgressChanged( SeekBar seekBar, int progress, boolean fromUser )
    {
        progress = Math.round( ( (float) progress ) / interval ) * interval;
        persistInt(progress);
        callChangeListener( progress );
        seekBar.setProgress( progress );
        this.monitorBox.setText( progress + "" );
        updatePreference( progress );
    }
    
    0 讨论(0)
  • 2020-12-06 19:30

    Regarding the inability to move the slider, this is because its width is set to 80 (see params2) which is too narrow to allow sliding. After setting a reasonable width for it, e.g. 400, and the associated text view and a few mods to get it to compile with my SDK version it worked for me. One advantage this version has over many others is that the layout is done in the code instead of XML which allows an app to easily instantiate multiple sliders.

    0 讨论(0)
提交回复
热议问题