I want to use Seekbar in setting to choose number 1 to 10. Is there any way to do this? I extend PreferenceActivity
for my setting activity.
As I found from here, but I don't know how to create Seekbar inside of the PreferenceScreen
. Thank in advance.
Here is activity
public class UserSettingActivity extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings); }
}
And setting.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/pref_user_profile" >
<EditTextPreference
android:title="@string/pref_user_name"
android:summary="@string/pref_user_name_summary"
android:key="prefUsername"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_update_setting" >
<CheckBoxPreference
android:defaultValue="false"
android:key="prefSendReport"
android:summary="@string/pref_send_report_summary"
android:title="@string/pref_send_report" >
</CheckBoxPreference>
<ListPreference
android:key="prefSyncFrequency"
android:entries="@array/syncFrequency"
android:summary="@string/pref_sync_frequency_summary"
android:entryValues="@array/syncFrequencyValues"
android:title="@string/pref_sync_frequency" />
</PreferenceCategory>
</PreferenceScreen>
If you don't mind using the Android.Support.v7.Preference Library, then you can use SeekBarPreference.
You could then use in XML:
<SeekBarPreference
android:key="keyName"
android:title="Property Label"
android:summary="Summary."
android:max="5"
android:defaultValue="0" />