How To Show Custom Thumb When Using Fastscrollenabled
I have a listview of countries in non-alphabetic order and started using fastscroll. I would like to display the country-flag when scrolling with fastscroll but it seems like the A
Solution 1:
In your ListView XML definition, add
android:fastScrollEnabled="true"
or in code
listView.setFastScrollEnabled(true);
Create file fastscroll_thumb.xml in the res/drawable folder as follows:
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"android:drawable="@drawable/fastscroll_pressed" /><itemandroid:drawable="@drawable/fastscroll" /></selector>
In AndroidManifest.xml, set a custom theme for your application:
<applicationandroid:theme="@style/ApplicationTheme"...>
Create a values folder in the res folder. Create themes.xml files in res/values as follows:
<resources><stylename="ApplicationTheme"><itemname="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item></style></resources>
Lastly make sure that fastscroll.png and fastscroll_pressed.png exist in your drawable folder
(optional) You can also set fast scroll always visible while you are debugging if you like
listView.setFastScrollAlwaysVisible(true);
or in XML
android:fastScrollAlwaysVisible="true"
Post a Comment for "How To Show Custom Thumb When Using Fastscrollenabled"