Defing your UI in XML and inflating it is the preferred way of implement your user interfaces (UIs), as it neatly decouples your application logic from your UI design.
1. In the MainActivity.java file, add the line below to the onCreate method. This will inflate, or display, a layout named main.xml that is located in the res/layout folder.
setContentView(R.layout.main);
2. Compile and run!
Resources:
Popular Posts
- android:textColorHighlight - Set the Color of Highlighted Text in an EditText
- android:ellipsize - Add an ellipsis(...) in a TextView
- Perform an Action after Enter keypress on EditText
- How to Register an Activity that Responds to NFC tags for URI's that point to a URL
- How to Import a Library
- Deprecated: android:singleLine - Set EditText to One Horizontally Scrolling Line
- android:drawablePadding - Add Padding to a Drawable in a TextView, in XML
- android:alpha - Set the Opacity/Transparency of Text in TextView/EditText
- String.valueOf - How to Convert a Double to a String
- How to Set Permission for I/O Operations over NFC