android – populate a recycler adapter from databases-ThrowExceptions

Exception or error:

I’m trying to add data (objects) to an adapter, (for a recycler view) from many databases. Theres two recycler views (both use view pagers) A and B, the data in A can change and anything in A should be movable to B, what i did was create a class that makes objects and then made an array list that holds the objects so in A id have my array list

 List<CardWriter> cardMakerList = new ArrayList<>();

and add it to my adapter

 cardAdapter = new CardAdapter(cardMakerList);

then add items to it and update the adapter

CardWriter cardWriter = new   
CardWriter(getResources().getDrawable(R.drawable.happy),"HAPPY"," happy");

if i wanted to change the data i could

CardWriter  cardWriter = new   
CardWriter(getResources().getDrawable(R.drawable.sad),"SAD","sad ");

and for adding items to B i could get the position of the item from the onClick method. The adapter ive used for B has almost identical variables and methods so i could use this


and it works fine but ive now started using databases so what i had:

 List<CardWriter> cardMakerList = new ArrayList<>();

becomes this:

 List<addNewCard> cardMakerList = new ArrayList<>();

to change the data its a new database so it changes to this

List<simpleNewCard> cardMakerList = new ArrayList<>();

but trying to add this new data to my (A) adapter doesnt work as its expecting addNewCard (even though the methods and properties are identical) it gives me an error like

CardAdapter(java.util.List<greendao.addNewCard>) in CardAdapter cannot be 
applied to (java.util.List<greendao.addSimpleCard>)

so i don’t want to make lots of different adapters i just want one for recycler view adapter A and one for the recycler view adapter B.
I’ve posed this question lately on here and had someone reply that i could make them implement a common interface or abstract Card class and make a List of that, I’m a novice programmer and have spent the last few days studying this and trialling different things, but I’m using a project called GreenDao and i don’t know how to implement this can anyone give me some pointers

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *