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
- Save LogCat to a Text File
- Perform an Action after Enter keypress on EditText
- android:ellipsize - Add an ellipsis(...) in a TextView
- How to Register an Activity that Responds to NFC tags for URI's that point to a URL
- setVisibility() - Hide a TextView, in Java
- android:nextFocusDown - Set Next Focus to a TextView/EditText
- Intent setType(String type) - How to Set an Explicit MIME data type
- android:nextFocusRight - Set the Next Focus Right to a TextView/EditText
- android:textColorHint - Set the Color of Hint Text in TextView/EditText
- Solution: Running Android Lint has encountered a problem Failed