class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) fragmentTransaction { ft -> ft.add(R.id.fragment_container, MainFragment()) } } fun AppCompatActivity.fragmentTransaction(transaction: (ft: FragmentTransaction) -> Unit) { val ft = supportFragmentManager.beginTransaction() transaction(ft) ft.commit() } }
0 件のコメント:
コメントを投稿