Using a layout file requires the android:fastscrollenabled= "true", as shown in the following code:
<listview android:id= "@+id/listview" android:layout_width= "fill_parent" android:layout_height= "Fill_ Parent "android:fastscrollenabled=" true " android:focusable=" true " />
Using Java code requires calling the Abslistview. setfastscrollenabled (Boolean enabled) method. As shown in the following code:
ListView listview=new ListView (Getapplicationcontext ()); Listview.setfastscrollenabled (TRUE);
The ListView component does not provide an API to modify the speed slider image, so you cannot modify the speed slider image directly. However, the fast speed slider image can be modified by reflection technology, as follows:
Fastscroller.mthumbdrawable variable saves a quick slider image //First to get Fastscroller object by abslistview.mfastscroller Field field = AbsListView.class.getDeclaredField ("Mfastscroller"); Field.setaccessible (true); Object Object=field.get (listView); Gets the object of the fastscroller.mthumbdrawable variable field=field.gettype (). Getdeclaredfield ("mthumbdrawable"); Field.setaccessible (true); Gets the value of the fastscroller.mthumbdrawable variable drawable drawable= (drawable) Field.get (object); Loads a new Quick slider object drawable=getresources (). getdrawable (r.drawable.img); Reset the speed skating block object Field.set (object,drawable); Set the minimum number of pages field. Setaccessible (true); Field minpages =object.getclass (). Getdeclaredfield ("Min_pages"); Minpages.setaccessible (TRUE);
==================================================================================================
Ouyangpeng welcome reprint, sharing with people is the source of progress!
Reprint please keep the original address : Http://blog.csdn.net/ouyang_peng
==================================================================================================
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
My Android Step-by-step tour------> How to add a fast speed slider to a ListView component and modify the speed slider image