https://github.com/Mussa-Adolai/MyRecycler/tree/edit_project
enter code here
from main activity
fun bottomNavClick(){ bottomNavigationView?.setOnItemSelectedListener(){
when(it.itemId){
R.id.home -> {
chooseFragment(PersonFragment(),"HOME")
}
R.id.profile->{
chooseFragment(RecyclerFragment(),"PROFILE")
Toast.makeText(this,"recyclerFragment", Toast.LENGTH_SHORT)
}
}
true
}
}
from fragment class
class PersonFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
Toast.makeText(activity,"PersonFragment", Toast.LENGTH_SHORT)
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_person, container, false)
}