Load the XML Resource

When you compile your application, each XML layout file is compiled into a View resource. You should load the layout resource from your application code, in your Activity.onCreateQ callback implementation. Do so by calling setContentView() , passing it the reference to your layout resource in the form of: R.layout. layout file name For example, if your XML layout is saved as main layout.xml, you would load it for your Activity like so:

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView.(R.layout.main layout);

The onCreate() callback method in your Activity is called by the Android framework when your Activity is launched (see the discussion on Lifecycles, in the Application Fundamantals, for more on this).

0 0

Post a comment