lundi 4 juillet 2016

Add a seekbar in preferences

I've made a preference-list. I get it from the code

 addPreferencesFromResource(R.xml.preferencelayout);

This gets me to my preferencelayout.xml file as contains the following:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory android:title="Settings">
<ListPreference
   android:key="listPref"
   android:title="Shake sensitivity"
   android:summary=""
   android:entries="@array/listArray"
   android:entryValues="@array/listValues"
   android:defaultValue="165" />


   <SeekBarPreference
   android:defaultValue="22"
   android:title="Set the default time"
   android:key="seekBar">
   </SeekBarPreference>

 <CheckBoxPreference
   android:key="checkboxPref"
   android:title="Autodecrease music"
   android:summary=""
   android:defaultValue="true"/>
 </PreferenceCategory>
 </PreferenceScreen>

When I press the SeekBarPreference button, a dialog comes up with the Seekbar and with 2 buttons, save and cancel!

Here comes my question:

Can I add a textview or something to be shown beside the seekbar to view which value that the seekbar is currently pointing at?

How can I get the value the user has entered?

Thanks!

Aucun commentaire:

Enregistrer un commentaire