Тэги:
#android_studio #code #coding #program #programming #tutorials #android #studio #java #kotlin #python #c# #how_to #app #applications #developer #developement #learn_coding #learn_programming #freeКомментарии:
I have managed to get this to work so I thought I should mention how I did this. Firstly really great video. This is solution for viewPager error around 10 mins into video. Similar to adding implementation you need to add the following in same build.gradle, this is all for kotlin ,
viewBinding {
enabled = true
}
then make sure you sync, then in Mainactivity.kt
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setUpTabs()
}
private fun setUpTabs(){
val adapter = ViewPagerAdapter(supportFragmentManager)
adapter.addFragment(HomeFragment(), "Home")
adapter.addFragment(FavouritesFragment(), "Favourites")
adapter.addFragment(SettingsFragment(), "Settings")
binding.viewPager?.adapter = adapter
binding.tabs?.setupWithViewPager(binding.viewPager)
thanks 👍
Ответитьfor the erro of not finding the viewPager.adapter = adapter its because you need binding to do so, just write binding.viewPager.adapter = adapter
ОтветитьR.drawable is already present in android studio use your custom Icons.
ОтветитьHey ...when I type in the viewpager I'd on the mainActivity part it doesn't recognize it from the xml😢
Ответитьthank you
Ответитьi get this error, "Classifier 'HomeFragment' does not have a companion object, and thus must be initialized here" is it really okay to just delete companion object in fragment?
ОтветитьThank you bro!!!
ОтветитьThank you for a nice content.
ОтветитьEverything did like in a video. IDE dont show any problems. But app is crashes when started without any error. What i've done wrong?
ОтветитьMine doesn't accept neither "ViewPagerAdapter" , nor "SupportFragmentManager". How can I do it with sectionsPagerAdapter and supportFragmentManager ?
Ответитьdidn´t work >:(
Ответитьicons are not showing in mine? anyone plz help
ОтветитьThanks helped a lot!
ОтветитьHello guys why my tab title didn't show in my tablayout?
Ответитьit is ridiculous how overcomplicated android development is, i mean jesus, in web development with html css and js it takes like 10 minutes, and it actually is intuitive
Ответитьhi i really needs help, my code didnt recognized the viewPager id. what should i do?
Ответить