How to solve java.lang.NoSuchMethodError: android.widget.AbsListView.isItemChecked

I am building an Android project against API level 11 (3.0) and I have this code:

if (parent instanceof AbsListView) {
    checked = ((AbsListView)parent).isItemChecked(position);
}

When I run this on pre-3.0 devices (below the API level 11), I get this error:

java.lang.NoSuchMethodError: android.widget.AbsListView.isItemChecked

In the AbsListView Documentation , isItemCheckeddeclared as compatible with API Level 1, why can I get an error?

+5
source share
1 answer

Apparently this is what happens:

Since API Level 1, the Android platform is already isItemCheckedon ListView.

API 11 Google isItemChecked AbsListView, ListView. ( pre-API 11) API 11, .class isItemChecked on AbsListView, pre- API 11.

API :

boolean isItemChecked(int) , AbsListView.

, . ListView, AbsListView. , AbsListView altogther.

+10

All Articles