package com.dafay.demo.viewbinding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import by.kirich1409.viewbindingdelegate.viewBinding
import com.dafay.demo.viewbinding.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity(R.layout.activity_main) {
    private val binding: ActivityMainBinding by viewBinding()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.btnReplace1.setOnClickListener {
            supportFragmentManager.beginTransaction()
                .replace(R.id.fl_content, Test01Fragment())
                .addToBackStack(null)
                .commit()
        }

        binding.btnReplace2.setOnClickListener {
            supportFragmentManager.beginTransaction()
                .replace(R.id.fl_content, Test02Fragment())
                .addToBackStack(null)
                .commit()
        }
    }
}