Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.implude.tutorial.intent">
package="com.implude.tutorial.intent">

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Intent">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Intent">
<activity android:name=".AnotherActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
13 changes: 13 additions & 0 deletions app/src/main/java/com/implude/tutorial/intent/AnotherActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.implude.tutorial.intent

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class AnotherActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_another)


}
}
9 changes: 9 additions & 0 deletions app/src/main/java/com/implude/tutorial/intent/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package com.implude.tutorial.intent

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val btn_open=findViewById<Button>(R.id.btn_open)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin에서 필드 이름은 camel case로 작성하는 것을 추천합니다. 따라서 btn_open보다는 btnOpen이 더 좋은 이름입니다. 더 자세한 내용은 여기를 참조하세요. 👍


btn_open.setOnClickListener{
startActivity(Intent(this, AnotherActivity::class.java))
}
}

}
22 changes: 22 additions & 0 deletions app/src/main/res/layout/activity_another.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AnotherActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AnotherActivity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textSize="50dp"
></TextView>
Comment on lines +9 to +18

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML 태그에 child가 없으면 바로 닫는 것을 추천합니다.
e. g.

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="AnotherActivity" />




</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_open_another_activity"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">Intent</string>
<string name="text_hello_intent">Hello Intent!</string>
<string name="text_open_another_activity">Open AnotherActivity</string>
<string name="app_name">Intent</string>
<string name="text_hello_intent">Hello Intent!</string>
<string name="text_open_another_activity">Open AnotherActivity</string>
</resources>