Reputation: 653
in my new Android Project, i have the following Problem, when i want to get the current position in the RecyclerView:
Cannot resolve method 'getAdapterPosition()'
In my other Android Studio Projects, it's work's fine.
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 the build.gradle i have this:
compile 'com.android.support:recyclerview-v7:21.0.3'
Upvotes: 4
Views: 3285