Search code examples
androidlayoutsetting

How to apply fast scroll using PreferenceActivity?


I'm using ListPreference within PreferenceActivity. With this widget, is it possible to apply a fast scrolling to it? If yes, how can I do it?

Right now, I'm stuck with this screen, without fastscroll: enter image description here

My .XML source is:

<PreferenceCategory android:title="@string/label_settingfirstcategory" android:key="first_category">
    <ListPreference 
        android:key="updates_interval"
        android:title="@string/label_countrycode"
        android:summary="@string/label_countrycodesummary"
        android:entries="@array/countrycode"
        android:entryValues="@array/countrycode"

    />
</PreferenceCategory>

And my activity/java source is:

public class SettingsActivity extends PreferenceActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {        
        super.onCreate(savedInstanceState);        
        addPreferencesFromResource(R.layout.preferences);
    }
}


Solution

  • You can't do it in easy way. Default ListPreference does not allow fast scrolling.

    You can create you own ListPreferenceWithFastScrolling, extend it from DialogPreference and override showDialog method with your custom dialog, where you can implement everything you want.