Cant Call A Custom Added Method Into My Adapter (extends Recyclerview.adapter)
Thank you in advance and dont be very hard with me, it is my first question. I was trying to add a new item to my recyclerView through the adapter by declaring a method in my adapt
Solution 1:
addItem(String) is not a method of RecyclerView.Adapter, but of your MyAdapter subclass. Obviously, RecyclerView.Adapter has no knowledge of the existence neither of your MyAdapter nor of your addItem(String).
you can either change
private RecyclerView.Adapter mAdapter;
into
private MyAdapter mAdapter;
or cast mAdapter. E.g.
if (mAdater instanceof MyAdapter) {
((MyAdapter) mAdapter).addItem(...);
}
Post a Comment for "Cant Call A Custom Added Method Into My Adapter (extends Recyclerview.adapter)"