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
- Solution: error: Error parsing XML: unbound prefix
- android:background - Change the Background Color of an EditText
- android:requiresFadingEdge
- Cursor getColumnIndexOrThrow - Get the Index for a Column Name
- android:maxWidth - Set the Maximum Width of TextView
- Change the line spacing between lines of text in an TextView/EditText, using lineSpacingExtra
- Solution: Running Android Lint has encountered a problem Failed
- How to Register an Activity that Responds to NFC tags for URI's that point to a URL
- android:ellipsize - Add an ellipsis(...) in a TextView
- How to Install an SDK package