diff --git a/library/src/se/emilsjolander/stickylistheaders/WrapperViewList.java b/library/src/se/emilsjolander/stickylistheaders/WrapperViewList.java index fdf2b76..f523cc3 100644 --- a/library/src/se/emilsjolander/stickylistheaders/WrapperViewList.java +++ b/library/src/se/emilsjolander/stickylistheaders/WrapperViewList.java @@ -32,11 +32,14 @@ public WrapperViewList(Context context) { // Use reflection to be able to change the size/position of the list // selector so it does not come under/over the header try { - Field selectorRectField = AbsListView.class.getDeclaredField("mSelectorRect"); - selectorRectField.setAccessible(true); - mSelectorRect = (Rect) selectorRectField.get(this); + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { + Field selectorRectField = AbsListView.class.getDeclaredField("mSelectorRect"); + selectorRectField.setAccessible(true); + mSelectorRect = (Rect) selectorRectField.get(this); + } + - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { mSelectorPositionField = AbsListView.class.getDeclaredField("mSelectorPosition"); mSelectorPositionField.setAccessible(true); } diff --git a/sample/build.gradle b/sample/build.gradle index e9ed470..c3bb13a 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -17,7 +17,7 @@ android { defaultConfig { applicationId 'se.emilsjolander.stickylistheaders' minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 29 } sourceSets {