There are two implementation methods for Android UI: one is to directly hardcode the UI in the code, and the other is to layout the UI in XML. Because I need to draw some curves on The View, the view class is derived directly. You can use setcontentview (New customeview () to draw lines normally. Finally, when I put the derived classes of views such as customeview and Other Android built-in textview in XML, I set the UI of the activity through setcontentview (resourceid, the customeview class cannot be found on the Virtual Machine in logcat during runtime. The final result is to add the entire package name (as shown in red) to the XML, because the custom derived class is no longer in the classpath of the Java Virtual Machine.
<Com. Practice. fundtest.
Customeview
Android: Id = "@ + ID/fundview"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
/>
When the customeview class can be loaded normally, I want to get the Instance Object of customeview in the form of findviewbyid, but every time the findviewbyid class returns NULL. You can use findviewbyid to find the view object that comes with Android to get it correctly. Therefore, you can see whether the id value is not passed to the customeview instance when inflate XML in setcontentview, finally, we found that many attributes in XML are passed through the second parameter in the view constructor view (context, attributeset ATTR, however, my Derived classes only provide customeview (context) functions, so that the id value cannot be passed in. findviewbyid returns NULL.