Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is my listview not returning me to my DetailActivity.class when I'm clicking an item on listview  RSS feed

 
Batz Alcancia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chris Barrett
Bartender
Posts: 318
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!