We often use the code when the Findviewbyid, take pains, I have introduced a very trickery method, very useful, here again:
Public classKalebaseactivityextendsActivity {PrivateString TAG =getclass (). Getsimplename (); Public Final<eextendsView> E GetView (intID) {Try { return(E) Findviewbyid (ID); } Catch(ClassCastException ex) {LOG.E (TAG,"Could not cast View to concrete class.", ex); Throwex; } }}
Write this into the activity's parent class, and you'll get the control later with GetView. Of course, if you are still accustomed to Findviewbyid, then the following two tools are absolutely right for you.
Creating an Findviewbyid interface from an XML layout
First, a simple and easy to use tool
http://android.lineten.net/layout.php
Second, a slightly more complex but powerful tool (recommended)
https://www.buzzingandroid.com/tools/android-layout-finder/
Automate the generation of Findviewbyid with online tools