Online Course Support

You have defined a graphical user interface in an XML layout file named myUI. You create a new activity in a file name MyActivity.java. How to you specify that MyActivity displays myUI?

Question 2
You have defined a graphical user interface in an XML layout file named myUI. You create a new activity in a file name MyActivity.java. How to you specify that MyActivity displays myUI?

1 point

In the onCreate method of MyActivity.java I use “myUI.display();”

In the onCreate method of MyActivity.java I call the setContentView method (without parameter) and in the root element of the myUI.xml file I indicate android:activity=”MyActivity”.

It’s impossible. Since the activity is named MyActivity, the system will try to load a layout named “activity_my.xml”.

In the onCreate method of MyActivity.java I use “”R.id.myUI.display();”

In the onCreate method of MyActivity.java I call the setContentView method and I provide “R.layout.myUI” as parameter.

In the onCreate method of MyActivity.java I call the onStart method and I provide “R.id.myUI” as parameter.

Similar Posts