Android

๋ทฐ๋ฐ”์ธ๋”ฉ ์ดˆ๊ธฐ ์ž‘์—…

๋…ธ๋ฃจ๋ฃฝ 2021. 2. 26. 22:44

1. build.gradle(Module:ํ”„๋กœ์ ํŠธ์ด๋ฆ„.app)์˜ android ๋ฐ‘์— ์ด ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€

    buildFeatures {
        viewBinding = true
    }

 

2. MainActivity.kt๋กœ ๊ฐ€์„œ ์ฝ”๋“œ ์ถ”๊ฐ€

class MainActivity : AppCompatActivity() {

    lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

    }
}