If you use other layouts in your activity, such as dialogs, you also need to load the layout before you can use the controls in the dialog box, such as TextView, and so on.
Such as:
View view = View.inflate (This,r.layout.dialog,null);
TextView TextView = (TextView) View.findviewbyid (R.id.textview);
Textview.settext ("ASAFDA");
And if you use This.findviewbyid, you'll get an error.
There are three ways to generate Lyaoutinflater
Layoutinflater Inflater = Layoutinflater.from (this);
Layoutinflater inflater = Getlayoutinflater ();
Layoutinflater Inflater = (layoutinflater) this.getsystemservice (Layout_inflater_service);
Then call the inflate method to turn the XML layout file into view
Public View Inflate (intresource,viewgrouproot,booleanattachtoroot)
In the view class, there are also inflate methods
public static View Inflate (Contextcontext,intresource,viewgrouproot)
Android-Load layout