diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 827b9d4..0e9dd2e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,13 +12,15 @@ - + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/Lesson4Activity.java b/app/src/main/java/com/example/Lesson4Activity.java new file mode 100644 index 0000000..ab22a31 --- /dev/null +++ b/app/src/main/java/com/example/Lesson4Activity.java @@ -0,0 +1,66 @@ +package com.example; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +public class Lesson4Activity extends AppCompatActivity { + private final String TAG = "DEBUG_" + Lesson4Activity.class.getSimpleName(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.d(TAG, "onCreate"); + setContentView(R.layout.activity_lesson4); + + // Viewを取得 + Button button = findViewById(R.id.lesson4_button); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(getApplicationContext(), Lesson4SubActivity.class); + startActivity(intent); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + Log.d(TAG, "onStart"); + } + + @Override + protected void onRestart() { + super.onRestart(); + Log.d(TAG, "onRestart"); + } + + @Override + protected void onResume() { + super.onResume(); + Log.d(TAG, "onResume"); + } + + @Override + protected void onPause() { + super.onPause(); + Log.d(TAG, "onPause"); + } + + @Override + protected void onStop() { + super.onStop(); + Log.d(TAG, "onStop"); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + Log.d(TAG, "onDestroy"); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/Lesson4SubActivity.java b/app/src/main/java/com/example/Lesson4SubActivity.java new file mode 100644 index 0000000..1f4d5a2 --- /dev/null +++ b/app/src/main/java/com/example/Lesson4SubActivity.java @@ -0,0 +1,64 @@ +package com.example; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +public class Lesson4SubActivity extends AppCompatActivity { + private final String TAG = "DEBUG_" + Lesson4SubActivity.class.getSimpleName(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.d(TAG, "onCreate"); + setContentView(R.layout.activity_lesson4_sub); + + // Viewを取得 + Button button = findViewById(R.id.lesson4_sub_button); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + Log.d(TAG, "onStart"); + } + + @Override + protected void onRestart() { + super.onRestart(); + Log.d(TAG, "onRestart"); + } + + @Override + protected void onResume() { + super.onResume(); + Log.d(TAG, "onResume"); + } + + @Override + protected void onPause() { + super.onPause(); + Log.d(TAG, "onPause"); + } + + @Override + protected void onStop() { + super.onStop(); + Log.d(TAG, "onStop"); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + Log.d(TAG, "onDestroy"); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_lesson4.xml b/app/src/main/res/layout/activity_lesson4.xml new file mode 100644 index 0000000..22ea468 --- /dev/null +++ b/app/src/main/res/layout/activity_lesson4.xml @@ -0,0 +1,28 @@ + + + + + +