Created
September 28, 2014 07:07
-
-
Save Harinder/e6ef98a04788f5e777f5 to your computer and use it in GitHub Desktop.
Android: Programmatically set the listSelector for a ListView to the default for the current theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void setDefaultListSelector(ListView listView, Context context) { | |
TypedArray typedArray = context.obtainStyledAttributes(null, new int[]{android.R.attr.listSelector}, android.R.attr.listViewStyle, 0); | |
Drawable drawable = typedArray.getDrawable(0); | |
listView.setSelector(drawable); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You saved my life 👍 Thank you so much.