โญ Activity์ ์ ์
โญ findViewById์ ์๋ฆฌ ๋ฐ ์ฌ์ฉ๋ฒ
โญ ViewBinding์ ์๋ฆฌ ์ฌ์ฉ๋ฒ
viewBinding{
enabled true
}
โญ findViewById๋ณด๋ค ViewBinding์ด ๊ถ์ฅ๋๋ ์ด์
โญ Intent์ ์ ์
โญ ๋ช ์์ Intent์ ์์์ Intent์ ์ฐจ์ด
val intent: Intent = Intent(this, DetailActivity::class.java)
startActivity(intent)
//startActivity() ํจ์๊ฐ ์ธํ
ํธ๋ฅผ ์์คํ
์ ์ ๋ฌ!
=> DetailActivity ์ ์ ๋ณด๋ฅผ Intent ๊ฐ์ฒด์ ๋์
ํ ๊ฒ
1) ๋ช ์์ ์ธํ ํธ: ํด๋์ค ํ์ ๋ ํผ๋ฐ์ค ์ ๋ณด๋ฅผ ํ์ฉํ ์ธํ ํธ=> ์ ์ฝ๋์์
DetailActivity::class.java
2) ์์์ ์ธํ ํธ: ์ธํ ํธ ํํฐ ์ ๋ณด๋ฅผ ํ์ฉํ ์ธํ ํธ=> ์ธ๋ถ ์ฑ์ ์ปดํฌ๋ํธ์ ์์ฒญ ์ฒ๋ฆฌ...
< activity > Activity์ ๊ฐ ํ์ ํด๋์ค. ์ด ํ๊ทธ ๋ด์ intent filter๊ฐ ์กด์ฌํ๊ณ , < intent-filter >ํ๊ทธ ์์๋ < action >๊ณผ < category >๊ฐ ์กด์ฌํ์ฌ ์ฒซ ํ๋ฉด์ ๊ฒฐ์ ํ๋ค.
โญ Intent๋ฅผ ์ฌ์ฉํ์ฌ Activity ๊ฐ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ
์ด ์์์ย ย ์์๋ ์ด ํ๋์ด ๋ฐ์ดํฐ๋ฅผ ์ ์กํ๋๋ก ์ง์ ํฉ๋๋ค.ย ํ๋์ด ์์ ์์ฒญ์ ์์ ํ ์ ์๋๋กย ย ์์๋ฅผย ์ ์ธ ํฉ๋๋ค.ย DEFAULT
<ย data>ย ์์๋ ์ด ํ๋์ด ๋ณด๋ผ ์ ์๋ ๋ฐ์ดํฐ ์ ํ์ ์ง์ ํฉ๋๋ค.
```
<activity android:name=".ExampleActivity" android:icon="@drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
```
```
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, textMessage)
}
startActivity(sendIntent)
```
โญ Fragment์ ์ ์
-ํ
์คํธ๋ทฐ๋ ๋ฒํผ์ฒ๋ผ ์กํฐ๋นํฐ ํ๋ฉด์ ๊ตฌ์ฑํ๋ ๋ทฐ
-์ด ์์ฒด๋ง์ผ๋ก๋ ํ๋ฉด์ ์๋ฌด๊ฒ๋ ์ถ๋ ฅ๋์ง ์๋๋ค!
-์กํฐ๋นํฐ์ฒ๋ผ ์๋ํ๋ค.
โ ์กํฐ๋นํฐ์์ ์์ฑํ๋ ๋ชจ๋ ์ฝ๋๋ ํ๋๊ทธ๋จผํฐ์์๋ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค!
โญ Fragment๋ฅผ ์ฌ์ฉํ๋ ์ด์
dependencies{
(...)
implementation 'androidx.fragment: fragment-ktx:1.3.6'
}
//ktx: kotlin์ผ๋ก ์์ฑํ์! ์ด๊ฒ ์์ผ๋ฉด ์๋ฐ!
โญ Fragment๋ฅผ ๋์ฐ๋ ๋ฐฉ๋ฒ
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.MainFragment">
โญ Bundle์ ์ ์
โญ Intent์ Bundle์ ๊ฒฐํฉ ๋ฐฉ๋ฒ
val intent = Intent()
val bundle =Bundle()
bundle.putString("key","value")
intent.putExtra("bundle",bundle)
โ Bundle์ ๋ด๋ถ์ ์ผ๋ก Map์ ํ์ฉํด ๋ฐ๋ก ๋ฐ์ดํฐ๋ฅผ ๋ฃ์ด์ค๋ค.
โญ FragmentManager์ ์ ์
-ํ๋๊ทธ๋จผํธ๋ฅผ ๋ํ๊ณ , ์ญ์ ํ๊ณ , ๊ต์ฒดํ๊ณ , ๋ฐฑ์คํ์ ๋ํ๋ ํ๋ ๋ฑ์ ์ฑ
์์ง๋ class
โญ SupportFragmentManager vs. FramgentManager
-์กํฐ๋นํฐ์์ FragmentManager์ ์ ๊ทผํ๊ธฐ ์ํด์ getSpportFragmentManager ํ๋กํผํฐ๋ฅผ ์ฌ์ฉํ๋ค.