I am a beginner. I wrote it for personal study.
HelloSampleActivity.java
package com.websarva.wings.android.hellosample;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class HelloSampleActivity extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//--------------1
setcontentView(R.layout.activity_hello_sample);//--2
}
}
・ The above code is written in advance.
-Since the onCreate method is the method that is executed first when the Android application is executed, it is necessary to write in this method what is necessary for initial processing such as screen creation and data preparation.
-(1) calls the onCreate method of the parent class and describes the process. Since the Activity class must be created by inheriting the Activity class (or its child class), it is described by overriding the onCreate method defined in the Activity class.
・ ② sets the screen to be displayed by this app. The above code uses the one described in activity_hello_sample.xml as a screen, so the argument is "R.layout.activity_hello_sample".
-In Android development, the files in the res folder and the ** resources ** described in those files are handled as the management target of the Android application.
-In order to manage resources efficiently, Android uses ** int type constant ** to identify the file value.
-The class that summarizes int type constants is ** R class , and Android studio automatically adds it to it. This allows resources to be exchanged using constants ( R-values **) in the R class.
-In Java, constants are written in capital letters, but for R values, the written folder names and file names are used as they are in order to clarify the relationship with the actual folder hierarchy and file names. using
Recommended Posts