the Android Inflate () method is used to find a layout of the XML definition , but only to find and hide, not to find, and to display the functionality. One of the most recent projects I've been doing this is confusing me for days.
Android also has a similar approach to inflate () called Findviewbyid (), which can sometimes be used interchangeably, but there are differences:
If you use other layout in your activity, such as a dialog box layout, and you want to set the content of the other components on the layout, you have to use the inflate () method to find the layout of the dialog box and then use Findviewbyid () Find the other components above it. For example:
View view1=view.inflate (this,r.layout.dialog_layout,null);
textviewdialogtv= (TextView) View1.findviewbyid (R.ID.DIALOG_TV);
Dialogtv.settext ("ABCD");
Note: R.ID.DIALOG_TV is a component on the layout of the dialog box, and if you use This.findviewbyid (R.ID.DIALOG_TV) you will get an error.
View viewstub = ((viewstub) Findviewbyid (R.id.stubview)). Inflate ();
Inflate () can be understood as "recessive expansion", hidden in view, inflate () before just get control, but no size does not occupy the space in the view, inflate () after a certain size, just in the hidden state.
The above is a simple description of the Android Inflate () method, hoping to help students in need.