The problem with the development of the last Wednesday is that my XML is fine, but every time I add a click event to the control, it crashes. Because the development is going on the line, so the exception processing all write to a file sent to the server, debugging will not print log. I was really ignorant, I think it can not be a code problem, has been looking for logic problems, but also to see the log (Khan .... Found this is the error, check the exception is because of the type inconsistency, that is, type conversion error, remember to write Java code before the time will also encounter such as an integer variable with string type to get the error.
Then I took a look at the error code line, which was wrong when I findbyid.
That's what I'm defining in XML is a ImageButton,
But when I call this ID in the code, I think of it as a button call.
The code is like this
Comebackbutton = (Button) Findviewbyid (R.ID.COMEBACK_BTN)//This comeback_btn is my definition of the ImageButton, that is, the conversion is wrong.
Because I this cloth interface and I write data interface is separated for a long time, forget reason.
Summary: 1, write code to be careful
2, do not take for granted that which is which, to be realistic.
This article is from the "unity of Knowledge" blog, please be sure to keep this source http://poarry.blog.51cto.com/5970996/1560412
Java.lang.ClassCastException:android.widget.ImageButton problems