Reputation: 1249
The purpose of the XML layout is confusing for me, having only worked with UI in Visual Studio with the drag-drop xml layout and C# code-behind. Should I be creating a separate xml layout for every screen (load, main, data) in my application? How do views associate with layouts? How do I reference the xml and use it in my code? I only know of the setContentView(xml layout) call.
For example, for my loading screen I want to display a background image and a loading bar. I'm thinking there's a way for the layout to contain the picture and the widget so the user sees the loading screen immediately, and in the actual code I'm initializing all my necessary variables.
Upvotes: 1
Views: 1377
Reputation: 2818
If you are confused on how layout works in Android, better try reading this topic on XML Layouts and also read this tutorial about user interface in Android for a head start.
Here's also a tutorial on how to set background image to progress bar.
You should load the layout resource(main.xml
) from your application code, in onCreate
method of your Activity
.
setContentView(R.layout.main);
Upvotes: 1
Reputation: 116
Yes, you need an XML file for every page of your application. Write a XML file for that particular page mentioning the fields required and in your .java file use this command
setContentView(R.layout.main);
Upvotes: 0