aspose file tools*
The moose likes Android and the fly likes please explain this unknown ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "please explain this unknown ClassCastException" Watch "please explain this unknown ClassCastException" New topic
Author

please explain this unknown ClassCastException

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1109
this is my activity.xml file



this is my Leave.java class



when i run this code i am getting below error?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41809
    
  62
What kind of object is the code retrieving? And what kind of object is it trying to cast it to? And what kind of cast is the error message complaining about? Answer these 3 questions, and you should be on your way to solving the problem.

(I am surprised the code even builds. I wouldn't have thought that having multiple UI elements in one layout file with the same ID even works. At the least, it's majorly confusing. But that has nothing to do with the issue at hand - it's an additional problem.)


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41809
    
  62
On taking a second look - what is the relationship between the code and the layout file? They don't seem to go together.
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95


On line 35: You are trying to get a view which is actually a LinearLayout and cast it to a Button. That is why you get a ClassCastException.
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95


I am sorry:

In line 35..................
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please explain this unknown ClassCastException