I have an abstract adapter class from an external library:
public abstract class DragItemAdapter<T, VH extends DragItemAdapter.ViewHolder> extends RecyclerView.Adapter<VH> {
//Their other codes
public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(final View itemView, int handleResId) {
super(itemView);
//The rest of their codes
}
}
}
And I have my Adapter extended that adapter
public class ChecklistAdapter extends DragItemAdapter<Pair<Integer, SomeClass>, ViewHolderForChecklist> {
@Override
public ViewHolderForChecklist onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
grab = R.id.grab;
return new ViewHolderForChecklist(view,grab);
}
}
If my ViewHolderForChecklist
is an inner class of the ChecklistAdapter
it works fine. But if I move the ViewHolderForChecklist
to a brand new class
public class ViewHolderForChecklist extends DragItemAdapter<Pair<Long, SomeClass>, ViewHolderForChecklist>.ViewHolder { // The error is at this line
public ViewHolderForChecklist(final View itemView, int grab) {
super(itemView, grab);
}
@Override
public void onItemClicked(View view) {
}
@Override
public boolean onItemLongClicked(View view) {
return true;
}
}
There is an error in real time
No enclosing instance of type 'library.package.name.DragItemAdapter' class is in scope
and the error when compile
error: an enclosing instance that contains DragItemAdapter.ViewHolder is required
Using "move" from Refractor has the same problem. I'm still new to this kind of... 'nested-class" so I don't know what is wrong with this or what kind of info should I include more.
Thank you!