Skip to content

Instantly share code, notes, and snippets.

@Harinder
Created September 28, 2014 07:07
Show Gist options
  • Save Harinder/e6ef98a04788f5e777f5 to your computer and use it in GitHub Desktop.
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
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);
}
@natuanorg
Copy link

You saved my life 👍 Thank you so much.

@m4xp1
Copy link

m4xp1 commented Nov 18, 2017

Thanks! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment