Skip to content

Commit

Permalink
[Chore/#25] 바텀 네비게이션과 ListFragment 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoncheong committed Jul 10, 2023
1 parent 2f8b10a commit ed3943d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
package com.sopt.umbba_android.presentation

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityMainBinding
import com.sopt.umbba_android.presentation.home.HomeFragment
import com.sopt.umbba_android.presentation.qna.QuestionAnswerActivity
import com.sopt.umbba_android.presentation.list.ListFragment
import com.sopt.umbba_android.presentation.setting.SettingFragment
import com.sopt.umbba_android.util.binding.BindingActivity

class MainActivity :BindingActivity<ActivityMainBinding>(R.layout.activity_main){
class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initView()
setBottomNav()
}

private fun initView(){
private fun initView() {
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_main)
if (currentFragment == null) {
changeFragment(HomeFragment())
}
}
private fun setBottomNav(){
binding.bnvMain.run(){

private fun setBottomNav() {
binding.bnvMain.run() {
setOnItemSelectedListener {
changeFragment(
when(it.itemId){
when (it.itemId) {
R.id.menu_home -> HomeFragment()
R.id.menu_setting -> SettingFragment()
else -> HomeFragment()
else -> ListFragment()
}
)
true
}
}
}

private fun changeFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fcv_main, fragment)
Expand Down

0 comments on commit ed3943d

Please sign in to comment.