Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Already add method for 1.3.1 but when Debug in real device had been stop working #78

Open
magicbusiness opened this issue Apr 6, 2021 · 0 comments

Comments

@magicbusiness
Copy link

    val bottomNav: MeowBottomNavigation = findViewById(R.id.meow_bottom_nav)

    bottomNav.add(MeowBottomNavigation.Model(0, R.drawable.vector_home))
    bottomNav.add(MeowBottomNavigation.Model(1, R.drawable.vector_explore))
    bottomNav.add(MeowBottomNavigation.Model(2, R.drawable.vector_chat))
    bottomNav.add(MeowBottomNavigation.Model(3, R.drawable.vector_notifications))
    bottomNav.add(MeowBottomNavigation.Model(4, R.drawable.vector_person))

    bottomNav.setOnClickMenuListener {
        when(it.id)
        {
            0 -> {
                Toast.makeText(this, "Home Fragment", Toast.LENGTH_SHORT).show()
                fragment(HomeFragment.newInstance())
            }

            1 -> {
                Toast.makeText(this, "Explore Fragment", Toast.LENGTH_SHORT).show()
                fragment(ExploreFragment.newInstance())
            }

            2 -> {
                Toast.makeText(this, "Chat Fragment", Toast.LENGTH_SHORT).show()
                fragment(ChatFragment.newInstance())
            }

            3 -> {
                Toast.makeText(this, "Notifications Fragment", Toast.LENGTH_SHORT).show()
                fragment(NotificationsFragment.newInstance())
            }

            4 -> {
                Toast.makeText(this, "User Fragment", Toast.LENGTH_SHORT).show()
                fragment(UserFragment.newInstance())
            }

            else -> {
                Toast.makeText(this, "Home Fragment", Toast.LENGTH_SHORT).show()
                fragment(HomeFragment.newInstance())
            }
        }
    }

    //
    val homeFrag = HomeFragment()

// val exploreFrag = ExploreFragment()
// val chatFragment = ChatFragment()
// val notificationFrag = NotificationsFragment()
// val userFrag = UserFragment()

    //
    fragment(homeFrag)
}

private fun fragment(fragment: Fragment)
{
    val fragmentManager = supportFragmentManager
    val fragmentTransaction = fragmentManager.beginTransaction()

    fragmentTransaction.replace(R.id.frame, fragment).addToBackStack(Fragment::class.java.simpleName)
    fragmentTransaction.commit()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant