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
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
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 );
}
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.