Home oynasi class sifatida elon qilindi va fragmentdan ikki nuqta orqali voris olindi


}//itemdagi bosilishni eshtib oldik va viewmodelga berib yubordik


Download 1.99 Mb.
bet2/4
Sana17.06.2023
Hajmi1.99 Mb.
#1552709
1   2   3   4
Bog'liq
Isomov

}//itemdagi bosilishni eshtib oldik va viewmodelga berib yubordik

adapter.setRootListener {//adapterdagi item bosilishini sezuvchi metod
val bundle = Bundle()//bundle obektini ozgaruvchiga saqladik
bundle.putSerializable("word", it)//malumotni it korinishida berdik
preventTwoClick(requireView())//malumotni keyingi oynaga bundle qilib berib yubordik , va ikki marta bosilishni oldini oldik
findNavController().navigate(R.id.action_homeFragment_to_wordMeaningFragment, bundle)//jeetpack navigation orqali bir oynadan boshqa oynaga o`tdik
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {//ko`rinishni obektini yaratdik ya`ni viewni yaratdik , bu onViewCreated metodini qayta yosish orqali amalga oshiriladi , endi bu iynada barcha kodlarimizni yozishda davom ettira olamiz.

binding.imgMenu.setOnClickListener {//xml dagi knopkani bosilishini eshtish


binding.drawerLayout.openDrawer(GravityCompat.START)//drawerlayoutni start qildik
}
binding.navigationView.setNavigationItemSelectedListener {//drawerni ishga tushurish jarayoni
when (it.itemId) {//Bu kotlinda when javada switch case vazifasini bajaradi
R.id.about ->//about knopkasini bosilishi
{ findNavController().navigate(HomeScreenDirections.actionHomeFragmentToAboutScreen())
//about oynasiga o`tish
binding.drawerLayout.closeDrawer(GravityCompat.START)
} binding.drawerLayout.closeDrawer(GravityCompat.START){//drawerni ishga tushurish jarayoni
findNavController().navigate(HomeScreenDirections.actionHomeFragmentToSavedWordFragment())//qidiruv oynasiga o`tish
}
R.id.exit_app -> {//chiqish knopkasini bosilishini sezish
requireActivity().finish()//activitiyni finish qildik
}//ilovadan chiqib ketish
}
return@setNavigationItemSelectedListener true//operatsiya bajarilishi haqidagi elon

Download 1.99 Mb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling