diff --git a/app/src/main/kotlin/jackall/moncalc/activity/MainActivity.kt b/app/src/main/kotlin/jackall/moncalc/activity/MainActivity.kt index 7fcd034..2a0d9d8 100644 --- a/app/src/main/kotlin/jackall/moncalc/activity/MainActivity.kt +++ b/app/src/main/kotlin/jackall/moncalc/activity/MainActivity.kt @@ -5,18 +5,23 @@ import android.os.Bundle import android.support.v7.app.AppCompatActivity import jackall.moncalc.R +import jackall.moncalc.adapter.MainFragmentPagerAdapter import jackall.moncalc.databinding.ActivityMainBinding import jackall.moncalc.viewmodel.MainViewModel +import kotlinx.android.synthetic.main.activity_main.view.* /** * Created by matsumoto_k on 2017/11/03. */ class MainActivity : AppCompatActivity() { val mainBinding by lazy { DataBindingUtil.setContentView(this, R.layout.activity_main) } - val mainViewModel by lazy { ViewModelProviders.of(this, MainViewModel.Factory()).get(MainViewModel::class.java) } + val mainViewModel by lazy { ViewModelProviders.of(this, MainViewModel.Factory(this)).get(MainViewModel::class.java) } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mainBinding.mainViewModel = mainViewModel lifecycle.addObserver(mainViewModel) + mainBinding.root.main_view_pager.adapter = MainFragmentPagerAdapter(supportFragmentManager, this) + mainBinding.root.main_tab_layout.setupWithViewPager(mainBinding.root.main_view_pager) } } \ No newline at end of file