Why is my listview not returning me to my DetailActivity.class when I'm clicking an item on listview
posted 1 year ago
I am having trouble with my ListView. It always sends me back to my login page whenever I press an item on the list. It supposed to go to the details page.
HomeActivity
I learned this code on a youtube channel and I know i followed the instructions well and I'm always checking the intent and still the problem is there. Thank you Guys in advance.
This is my DetailActivity.class. Does this have my problem?
DetailActivity
Android Manifest
Product Class
The error is that the Product cannot be cast to java.io.Serializable
HomeActivity
I learned this code on a youtube channel and I know i followed the instructions well and I'm always checking the intent and still the problem is there. Thank you Guys in advance.

This is my DetailActivity.class. Does this have my problem?
DetailActivity
Android Manifest
Product Class
The error is that the Product cannot be cast to java.io.Serializable
posted 1 year ago
Hi Batz,
Welcome to the Ranch!
In order to cast to Serializable, your Product class must implement the Serializable interface:
As objects within the Intent wrapper could be passed across Threads during the startActivity call, the objects needs to be in a data transferable state. That's where Serialization comes into play. For more information, consider reviewing: http://www.coderanch.com/t/660236/Wiki/Data-Transfer-Object
I'll add that using the Serializable interface in Android isn't a great idea. Serializable has a lot of baggage that in the resource limited Android world can slow down your app. Android has it's own, much more lightweight, version of Serializable called Parcelable. It's a bit tricky to implement, however, with lots of boilerplate code (google "parcelable generator" for sites that can help with that).
Welcome to the Ranch!
In order to cast to Serializable, your Product class must implement the Serializable interface:
As objects within the Intent wrapper could be passed across Threads during the startActivity call, the objects needs to be in a data transferable state. That's where Serialization comes into play. For more information, consider reviewing: http://www.coderanch.com/t/660236/Wiki/Data-Transfer-Object
I'll add that using the Serializable interface in Android isn't a great idea. Serializable has a lot of baggage that in the resource limited Android world can slow down your app. Android has it's own, much more lightweight, version of Serializable called Parcelable. It's a bit tricky to implement, however, with lots of boilerplate code (google "parcelable generator" for sites that can help with that).
