Skip to content
Advertisement

DataModel cannot be cast to java.util.ArrayList

I couldn’t find what the problem is. Logcat is saying :

“Caused by: java.lang.ClassCastException: com.example.project.model.DataModel cannot be cast to java.util.ArrayList”

I tried different solutions but none worked:

  • Parcelable
  • @SuppressWarning

Could someone show me what is wrong in my code please?

DataModel.Java

JavaScript

TableActivity.Java

JavaScript

DetailsActivity.Java

JavaScript

Advertisement

Answer

You are passing object on intent by doing this,

JavaScript

and on receiver side, you are expecting ArrayList. It should be like this

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement