TABLAYOUT WITH VIEWPAGER 2 (go to previous video to understand) CREATING SWIPABLE VIEWS WITH VIEWPAGER 2 (go to previous video about recycleview) The wheels on the bus go round and round round and round round and round All day long all day long.
Great quality! Amazing job thank you so much I'm watching the playlist now, my only feedback to make things easier to understand is that you use labels that are very close to the syntax which can make it difficult to follow along at times, for example it would be easier to understand what is syntax and what is definable if you used silly names like "super duper button" & "second best button" instead of just "first button" & "second button"That contrast would make this already amazing tutorial series even better I hope that makes sense
Thanks for the hard work. I can support you like this. After I finish my thesis (a complex android app in kotlin) I will recommend your channel (among a few others) in 2 facebook groups from my country with software developers. Around 60k people in there, some of them would be interested.
Thanks for another great tutorial! Was just wondering if you could create a video that deals with interacting with the items in the viewpagers and recyclerviews (such as onClickListeners) perhaps in the near future? :)
You can also pass a functrion with the adapter. Then you can make a onclick on the view itself now. Each time you press a onclick you can do a action defined in your "callback" function.
Naming suggestion: For the "item" layout, instead of "item_view_pager" (which makes it sound like it contains or represents a ViewPager, not the item), I'd suggest maybe something like "view_pager_item" (or "pager_item" or "gallery_item", etc). Hope that helps! Thx for the videos... great summaries and review for me!
Hey guys, I am using the latest android studio bumblebee 2021.1.1. In this version id of XML elements is not working. I have to use finfViewById() function for that. like in this tutorial viewPager.adepter is not working. the studio doesn't understand that pager. Any suggestion on this. please help me. Thanks.
Great tutorial! if i wanted to make the viewpager keep going based on dates (yesterday, today, tomorow... etc) instead of the pictures, how would i do that?
I have used viewpager2 to change fragment, but I don't know how to change the title of title bar of my activity as I swipe to other activity, I know I need to use toolbar.title="frag1" but don't know where to use that ☹️😟😕 ..... Please guide
Hello thank you very much for the content, I am trying to implement viewpager2 with jetpack, I don't use images but videos. This does not work correctly because the videos play once (others don't) and then simply none of them can play, do you know why this happens or how can I fix it?
Thank you for great videos. What is the fake dragging? and what is it used for? i understand that was changed image programatically. but it was in just create function and i couldnt imagine which area it is using.
use : when we set the offset (give a particular value) it means that while swapping how many images will scroll in one swap (in simpler words how fast the image can be scrolled in one swipe) do you get it
I created viewpager and inside that viewpager i loaded few fragment inside those fragments there are webviews . When iam scrolling that webview vertical it scrolls but not smoothly some time viewpager gets swiped. And though webview can be horizontally scrolled but it is not scrolling instead the viewpager is getting swiped. Please help me with this.
Thanks for the video. You're really amazing. I have a very complicated question I'd be really glad if you can help. Let's say I have up to a hundred images to swipe in my drawable folder. After clicking a button from an activity, it goes to a specific image number for example...image 21 instead of the 1st image, and the swiping starts from there. How do I implement that. I'd be glad if you can explain in java and not kotlin and if not, I will find my away around the concept. Thanks for your effort.
I follow step by step but i can't get it to work. has something changed for Flamingo? it doesn't recognize ivImage in the override fun onBindViewHolder and it doesn't recognize the viewPager.adapter = adapter. help would be appreciated
I searched through many videos, but I didn't find one in kotlin where someone selects multiple images from the gallery and displays them inside a recycler view. How should I pass the images from onActivityResult to the recycler view with data-binding? Should I include mvvm too? :D
I put your code with the adapter from onCreate to onResume and it works when uploading multiple images. Too bad I don't know if I can do that with data-binding
Is there any way now where you can zoom in to those images all while maintaining viewpager? I really want to learn how to have both features at the same time.
Then you need to always replace the next item in the recyclerview with the item you want to have next. And everytime the user swipes you replace the next one again (and the last one of course)
Hello Brother, Thanks for the awesome tutorial. I just have a small issue.... I've uploaded 6 images. The scroll is smooth for the first 3 images, but then it starts to lag when I try to scroll to the next 3 images. What could be the reason bro? Thanks in advance :-)
I have implemented it using view binding feature but I am having a problem that in the application on swiping some images reappear and some images didn't even appear i.e not every image is appearing exactly once please help me with it.....
Since kotlin-android-extenstions are deprecated, I couldn't do the holder.itemView.ivImage.setImageResource(curImage) part. Any suggestions for how to do it?
I've found a way to refactor the `ViewPagerAdapter` class using ViewBinding: class ViewPagerAdapter( private val images: List ) : RecyclerView.Adapter() { inner class ViewPagerViewHolder(val binding: ItemViewpagerBinding) : RecyclerView.ViewHolder(binding.root) override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder { val view = LayoutInflater.from(parent.context) val binding = ItemViewpagerBinding.inflate( view, parent, false ) return ViewPagerViewHolder(binding) } override fun onBindViewHolder(holder: ViewPagerViewHolder, position: Int) { val currentImage = images[position] holder.binding.apply { ivImage.setImageResource(currentImage) } } override fun getItemCount(): Int { return images.size } }
I couldn't continue with the tutorial at the part of the ViewPagerAdapter creation because it's made in Kotlin. I tried to understand how it works to make it on Java but I couldn't. I tried extending RecyclerView.ViewHolder but there are no methods to override. It would be good if you added to your video title "With Kotlin" so people like me that doesn't want to move away from JAVA can stay away or at least be prepared.... Thanks
A great job by you in being able to explain such a complicated topic so easily and making it easy to consume the concept of the new viewPager2
TABLAYOUT WITH VIEWPAGER 2
(go to previous video to understand)
CREATING SWIPABLE VIEWS WITH VIEWPAGER 2
(go to previous video about recycleview)
The wheels on the bus go round and round
round and round
round and round
All day long
all day long.
Thank you!
I've started to learn Kotlin recently. You explained this material very well
Thanks a lot, you're welcome🙏
your the best man!! your just the best... Kotlin + all the new Android libraries....bless you!
Great quality! Amazing job thank you so much
I'm watching the playlist now, my only feedback to make things easier to understand is that you use labels that are very close to the syntax which can make it difficult to follow along at times, for example it would be easier to understand what is syntax and what is definable if you used silly names like "super duper button" & "second best button" instead of just "first button" & "second button"That contrast would make this already amazing tutorial series even better
I hope that makes sense
Great Tutorial! Hello from Bishkek, Kyrgyzstan
Awesome! Thank you!
Thanks for the hard work. I can support you like this. After I finish my thesis (a complex android app in kotlin) I will recommend your channel (among a few others) in 2 facebook groups from my country with software developers. Around 60k people in there, some of them would be interested.
Thanks a lot for your support, glad my content helps you!!
Impressive. You make look everything super easy.
Thanks! :)
Great tutorial. I think you might be missing a `viewPager = findViewById` instruction at around 9:52
Nice tutorial, I have a question, please.
How to change the swiping orientation to the left.
(From the right to the left for Arabic app)
Thank you
Thanks for another great tutorial! Was just wondering if you could create a video that deals with interacting with the items in the viewpagers and recyclerviews (such as onClickListeners) perhaps in the near future? :)
Hey man, thanks! If you want to interact with the items you can do that in the RecyclerView adapter in onBindViewHolder
You can also pass a functrion with the adapter. Then you can make a onclick on the view itself now. Each time you press a onclick you can do a action defined in your "callback" function.
Thought this would be very complex. Thanks a lot for making this easy.
So glad that you use DARK THEME!!!!!!!!!!!!!!!!
Thank you so much. This helped me a lot to understand view pager.
Naming suggestion: For the "item" layout, instead of "item_view_pager" (which makes it sound like it contains or represents a ViewPager, not the item), I'd suggest maybe something like "view_pager_item" (or "pager_item" or "gallery_item", etc). Hope that helps! Thx for the videos... great summaries and review for me!
Thank you, worked like a charm!
Thank you so much!!! Quickly and easy :)
this is an awesome channel! thks so much for every tutorial videos! it's helping a lot!
You're very welcome!
Good explanation, thanks very much.
Hey guys, I am using the latest android studio bumblebee 2021.1.1. In this version id of XML elements is not working. I have to use finfViewById() function for that. like in this tutorial viewPager.adepter is not working. the studio doesn't understand that pager. Any suggestion on this. please help me. Thanks.
Same problem here.
findViewById(R.id.viewPager).adapter=adapter
for ActivityMain:
class MainActivity : AppCompatActivity() {
private lateinit var binding : ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
val images = listOf(
R.drawable.android,
R.drawable.ss,
R.drawable.ic_launcher_background
)
val adapter = ViewPagerAdapter(images)
binding.viewPager.adapter = adapter
}
}
For Adapter Class :
class ViewPagerAdapter(
val images : List
) : RecyclerView.Adapter() {
private lateinit var bind : ItemViewPagerBinding
inner class ViewPageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPageViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_view_pager, parent, false)
bind = ItemViewPagerBinding.bind(view)
return ViewPageViewHolder(view)
}
override fun onBindViewHolder(holder: ViewPageViewHolder, position: Int) {
val curImage = images[position]
holder.itemView.apply {
bind.ivImage.setImageResource(curImage)
}
}
override fun getItemCount(): Int {
return images.size
}
}
copy past this, it will work
Saved my day, thanks.
Refactoring `ViewPagerAdapter` with ViewBinding:
class ViewPagerAdapter(
private val images: List
) : RecyclerView.Adapter() {
inner class ViewPagerViewHolder(val binding: ItemViewpagerBinding) :
RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder {
val view = LayoutInflater.from(parent.context)
val binding = ItemViewpagerBinding.inflate(
view, parent, false
)
return ViewPagerViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewPagerViewHolder, position: Int) {
val currentImage = images[position]
holder.binding.apply {
ivImage.setImageResource(currentImage)
}
}
override fun getItemCount(): Int {
return images.size
}
}
What is ItemViewpagerBinding?
@@rehansyed89 It's the viewBinding class created for the binding if you've enabled viewBinding in build.gradle
It really helped me mate, thanks!
Thanks, very helpful!
Great tutorial! if i wanted to make the viewpager keep going based on dates (yesterday, today, tomorow... etc) instead of the pictures, how would i do that?
at 9:48 instead of using viewPager.adepter use this. findViewById(R.id.viewPager).adapter = adepter
This will work....
it helped, love u man
Thank you, your input is greatly appreciated!
thanks bro for ViewPager2
Nice, can plz share a way to use view binding in pager adapter? Thanks
Great ! It was very useful to mr
thanks for the video description implementaion :)
Mind blowing 😎
How can I combine this with the bottom navigation bar template, to get a swipeable view containing fragments?
i guess Im pretty randomly asking but does anybody know of a good place to stream newly released movies online ?
@Milo Mathew I watch on FlixZone. You can find it by googling :)
Yo, dude! Great videos, glad i found you. Do you have some material on tablayout and fragments? Thanks for the great videos!
Thanks man, yes I do! Take a look in this fundamentals Playlist, I have a separate video on each of those
implementation 'com.google.android.material:material:1.3.0-beta01'
Thanks for making video
Thanks bro, it helped me a lot
You're welcome!
No .. It's not a viewpager it just a another recyclerview 🤪😂
Great tutorial 🔥🔥
It's ViewPager2*
I have used viewpager2 to change fragment, but I don't know how to change the title of title bar of my activity as I swipe to other activity, I know I need to use toolbar.title="frag1" but don't know where to use that ☹️😟😕 ..... Please guide
You're awesome 👌
You too!
Thank you for the great content and explanation. It worked! :-D
You're welcome!
Great tutorial!, it is possible to preview of the image on both the left and the right? thanks!
Thanks, bro
Does this viewpager2 works similary with a BarLayout as the old Viewpager??
Sir, can we just use horizontal Recycler view instead of using viewpager?
Then you don't have the swiping functionality, instead you can scroll
@@PhilippLackner ohh yeah got it 👍👍👍👍 thank you 🙏🙏🙏🙏🤗🤗🤗 great content watching your all series. 🤗
Hello thank you very much for the content, I am trying to implement viewpager2 with jetpack, I don't use images but videos. This does not work correctly because the videos play once (others don't) and then simply none of them can play, do you know why this happens or how can I fix it?
How 2 swipe activities to left/right like overlapped game cards and with slight arc trajectory ?
Thank you for great videos. What is the fake dragging? and what is it used for? i understand that was changed image programatically. but it was in just create function and i couldnt imagine which area it is using.
Might be useful if you have additional controls such as a next and previous button and you want the viewpager to swipe if you click on these buttons
Might be useful if you have additional controls such as a next and previous button and you want the viewpager to swipe if you click on these buttons
@@PhilippLackner interesting
Can anyone please explain the functioning of fakeDrag, like what happens while implementing it?
use : when we set the offset (give a particular value) it means that while swapping how many images will scroll in one swap (in simpler words how fast the image can be scrolled in one swipe) do you get it
I created viewpager and inside that viewpager i loaded few fragment inside those fragments there are webviews . When iam scrolling that webview vertical it scrolls but not smoothly some time viewpager gets swiped. And though webview can be horizontally scrolled but it is not scrolling instead the viewpager is getting swiped. Please help me with this.
seems cool man
Can we these images from right to left?
Thanks for the video. You're really amazing.
I have a very complicated question I'd be really glad if you can help.
Let's say I have up to a hundred images to swipe in my drawable folder. After clicking a button from an activity, it goes to a specific image number for example...image 21 instead of the 1st image, and the swiping starts from there. How do I implement that.
I'd be glad if you can explain in java and not kotlin and if not, I will find my away around the concept. Thanks for your effort.
There is a function for viewpager called scrollToPosition which will do what the name says :D
@@PhilippLackner Oh ok.. I'll check it out. Thank you
@@PhilippLackner This method scrollToPosition is not found. Can you help?
I follow step by step but i can't get it to work. has something changed for Flamingo? it doesn't recognize ivImage in the override fun onBindViewHolder and it doesn't recognize the viewPager.adapter = adapter. help would be appreciated
findViewById(R.id.viewPager).adapter = adapter
as far I understand, author uses some plugin for Android Studio and that's why he can access identifiers in a such way 🙂
I searched through many videos, but I didn't find one in kotlin where someone selects multiple images from the gallery and displays them inside a recycler view. How should I pass the images from onActivityResult to the recycler view with data-binding? Should I include mvvm too? :D
I put your code with the adapter from onCreate to onResume and it works when uploading multiple images. Too bad I don't know if I can do that with data-binding
Hi, I tried to add dot indicator using TabsLayout and TabLayoutMediator. but its not showing Can you help me
How I can load the images using Glide? is it posible in this example?
Is there any way now where you can zoom in to those images all while maintaining viewpager? I really want to learn how to have both features at the same time.
And if I want an auto slideshow and infinite loop? How I have to do? Thanks
Then you need to always replace the next item in the recyclerview with the item you want to have next. And everytime the user swipes you replace the next one again (and the last one of course)
Thanks a lot
Hello Brother,
Thanks for the awesome tutorial. I just have a small issue.... I've uploaded 6 images. The scroll is smooth for the first 3 images, but then it starts to lag when I try to scroll to the next 3 images. What could be the reason bro?
Thanks in advance :-)
try using small size images, big size images often leads to buffer that leads to slowing up performance
Hello thanks for this tutorial it would be great if you provide the code of every tutorial !!
How to add both horizontal and vertical swapping in view pager 2
Please add dependency in description
no need dude , now we can implement it in xml directly
How can we use several different fragments?
I have implemented it using view binding feature but I am having a problem that in the application on swiping some images reappear and some images didn't even appear i.e not every image is appearing exactly once please help me with it.....
how's journey going bro ? developed some apps or not ?
Since kotlin-android-extenstions are deprecated, I couldn't do the holder.itemView.ivImage.setImageResource(curImage) part. Any suggestions for how to do it?
ViewBinding
@@PhilippLackner Thanks I'm trying to learn ViewBinding
@@mustafakorkmaz5702 Merhaba kardeşim, çözüm bulabildin mi?
@@berkayozgen259 bulamadım maalesef
I've found a way to refactor the `ViewPagerAdapter` class using ViewBinding:
class ViewPagerAdapter(
private val images: List
) : RecyclerView.Adapter() {
inner class ViewPagerViewHolder(val binding: ItemViewpagerBinding) :
RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder {
val view = LayoutInflater.from(parent.context)
val binding = ItemViewpagerBinding.inflate(
view, parent, false
)
return ViewPagerViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewPagerViewHolder, position: Int) {
val currentImage = images[position]
holder.binding.apply {
ivImage.setImageResource(currentImage)
}
}
override fun getItemCount(): Int {
return images.size
}
}
how to add buttons on viewpager. ex like btn.
How to implement an infinity swiper?
I couldn't continue with the tutorial at the part of the ViewPagerAdapter creation because it's made in Kotlin. I tried to understand how it works to make it on Java but I couldn't. I tried extending RecyclerView.ViewHolder but there are no methods to override.
It would be good if you added to your video title "With Kotlin" so people like me that doesn't want to move away from JAVA can stay away or at least be prepared....
Thanks
You can clearly see the kotlin icon in the video thumbnail
How use two or more ViewPager?
Hi how can i go from right to letf
i was wondering why from nothing switched to kotlin
what about cardview ????
**spends all night translating this into java somehow**
in that time you could've learned kotlin
@@PhilippLackner lol
How to find last swipe in viewpager 2 ?
just save the swipes and then check accordingly
Can someone help D: the $kotlin_version does not work and does not sync at all
My app is crashing after swiping last image
How do you get the image view without findViewById() at 08:39, you call holder.itemVIew.ivImage directly ?!?!
use viewBinding bro, findByView is old so dont use it, direct use of ivImage is deprecated so use viewBinding
Where is the code Bro!
i get this(Pages must fill the whole ViewPager), i tried a lot of solution even i watch the vido agin but still get it
plzz upload with java
plzzz learn with kotlin