1: Each activity class must be mapped in a androidmanifest.xml file. Otherwise null pointer exception.
The res directory of the 2:android is fixed and can only be of the following types:drawable,layout,values,xml,raw, Color
If you add a different directory, it will report the error ' Invalid resource directory name ',
3: Launch Android project, the app apk file will be generated in the bin directory.
4:res-drawable Analysis
DRAWABLE-HDPI high-resolution picture; drawable-mdpi place a medium-resolution picture; drawable-ldpi place a low-resolution picture
5: View Usage
(1) How to define a view in an XML file:
There is a res/layout directory under the source directory of the Android project, which is used to store the layout files.
Layout files are typically named after the activity's name, with. xml as the suffix.
When creating a component in XML, you need to specify an ID for the component, such as: The android:id= "@+id/name" system automatically creates the corresponding R resource class variable in the Gen directory.
(2) How to use views in activity:
When you create each activity in your code, you typically call Setcontentview () in the OnCreate () method to load the specified XML layout file.
You can then use Findviewbyid () to get a control of the corresponding ID created in the layout file, such as a button.
Such as:
Private Button Btnsndmag;
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Loading main.xml layout files
Setcontentview (R.layout.main);
Find the button component for with ID
Btnsndmag = (Button) This.findviewbyid (R.ID.BTNSNDMAG);
....
}
6: Five major layouts
LinearLayout (linear layout),
Framelayout (single frame layout),
Absolutelayout (absolute layout),
Tablellayout (table layout),
Relativelayout (relative layout).
The most commonly used ones are linearlayout, Tablellayout and Relativelayout.
These layouts can be used in nested nesting.
Android Rookie-Learn note 1