GetAdapterPosition () is not a method

in my new Android project, I have the following problem when I want to get the current position in RecyclerView:

Unable to resolve getAdapterPosition () 'method

In my other Android Studio projects, it works great.

    public static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    protected TextView itemName;
    protected ImageView itemIcon;

    public MyViewHolder(View v, UserClickListener listener) {
        super(v);
        // a- A
        mListener = listener;

        itemName = (TextView) v.findViewById(R.id.rowText);
        itemIcon = (ImageView) v.findViewById(R.id.rowIcon);

        v.setOnClickListener(this);
    }

    public void onClick(View v) { mListener.onClick(v, getAdapterPosition()); }
}

in build.gradle I have this:

compile 'com.android.support:recyclerview-v7:21.0.3'
+4
source share
1 answer

getAdapterPosition()is part of the v22 support library, so the only way to use it is to update it. Here you can find the change log.

+6
source

All Articles