http://blog.csdn.net/xyang81/article/details/17680333
There's a post on EoE. Changing the icon of a quick slide block by reflecting, dynamically modifying the Mthumbdrawable property of the Fastscroller object is not an implementation, but the reflection is less efficient. The following describes how to customize icons using style.
As you can tell from the Init method of the Fastscroller class, Mthumbdrawable is by acquiring the current activity theme of Android. R.attr.fastscrollthumbdrawable Property Assignment, since this is the case, we can completely customize a theme that covers Android. The R.attr.fastscrollthumbdrawable property corresponds to the drawable not to be done!
1. Define a Theme
<style name= "Listviewfastscrollthumb" parent= "@android: Style/theme.light.notitlebar.fullscreen" > <item Name= "Android:fastscrollthumbdrawable" > @drawable/ic_launcher</item></style>
2, the current ListView activity app custom Theme
<activity android:name= "com.example.actionbardemo.MainActivity" android:label= "@string/app_name" Android:theme = "@style/listviewfastscrollthumb" > <intent-filter> <action android:name= "Android.intent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> </INTENT-FILTER></ACTIVITY&G T
3. Verification
public class mainactivity extends ListActivity {private static final int[] ATTRS = new int[] { android. r.attr.fastscrollthumbdrawable, }; @Overrideprotected void oncreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Setlistadapter (New arrayadapter<string> (this, android. r.layout.simple_list_item_1, cheeses.scheesestrings));imageview imageview = (ImageView) findviewbyid (r.id.fastscrolldrawable); Theme theme = gettheme (); Typedarray a = theme.obtainstyledattributes (attrs);D rawable drawable = A.getdrawable (0); imageview.setbackgrounddrawable (drawable);}}
< Span style= "font-family:arial; font-size:18px; line-height:26px; Background-color:rgb (255, 255, 255); " > layout:
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android" xmlns: tools= "Http://schemas.android.com/tools" android:id= "@+id/container" android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:orientation= "Vertical" > <ImageView android:id= "@+id/fastscrolldrawable" android:layout_width= "Wrap_content" android:layout_ height= "Wrap_content" /> <ListView android:id= "@android: Id/list" android:layout_width= "match _parent " android:layout_height=" Match_parent " &Nbsp; android:fastscrollenabled= "true" /></ Linearlayout>
Demo:http://download.csdn.net/detail/xyang81/6788411
"Android" Custom ListView Quick Scroll bar