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
@АркадийБардамов4 жыл бұрын
Thank you! I've started to learn Kotlin recently. You explained this material very well
@PhilippLackner4 жыл бұрын
Thanks a lot, you're welcome🙏
@abostef774 жыл бұрын
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.
@iftak014 жыл бұрын
your the best man!! your just the best... Kotlin + all the new Android libraries....bless you!
@daiyrkanybekov85754 жыл бұрын
Great Tutorial! Hello from Bishkek, Kyrgyzstan
@PhilippLackner4 жыл бұрын
Awesome! Thank you!
@Diego175113 жыл бұрын
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
@starlite50974 жыл бұрын
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.
@PhilippLackner4 жыл бұрын
Thanks a lot for your support, glad my content helps you!!
@theodordimov6518 Жыл бұрын
Great tutorial. I think you might be missing a `viewPager = findViewById` instruction at around 9:52
@mandalsalman4 жыл бұрын
Impressive. You make look everything super easy.
@PhilippLackner4 жыл бұрын
Thanks! :)
@PrashantKumar-je4bs2 жыл бұрын
at 9:48 instead of using viewPager.adepter use this. findViewById(R.id.viewPager).adapter = adepter This will work....
@Et_tu2 жыл бұрын
it helped, love u man
@spencerdamon1248 Жыл бұрын
Thank you, your input is greatly appreciated!
@dirajnaik9869 Жыл бұрын
thanks bro for ViewPager2
@norulesprateek4 жыл бұрын
Thought this would be very complex. Thanks a lot for making this easy.
@Indently4 жыл бұрын
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? :)
@PhilippLackner4 жыл бұрын
Hey man, thanks! If you want to interact with the items you can do that in the RecyclerView adapter in onBindViewHolder
@teunstout67254 жыл бұрын
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.
@شاشةالمسلمالصغير4 жыл бұрын
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
@shareemteofilo62573 жыл бұрын
Thank you so much. This helped me a lot to understand view pager.
@mario330674 жыл бұрын
this is an awesome channel! thks so much for every tutorial videos! it's helping a lot!
@PhilippLackner4 жыл бұрын
You're very welcome!
@GriNAME2 жыл бұрын
Thank you so much!!! Quickly and easy :)
@nousernamethx3 жыл бұрын
Thank you, worked like a charm!
@PrashantKumar-je4bs2 жыл бұрын
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.
@emmanuelsawe9762 жыл бұрын
Same problem here.
@dirajnaik9869 Жыл бұрын
findViewById(R.id.viewPager).adapter=adapter
@ahappyperson65306 ай бұрын
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
@manishpingale65584 жыл бұрын
So glad that you use DARK THEME!!!!!!!!!!!!!!!!
@kevinbuguecio56734 жыл бұрын
It really helped me mate, thanks!
@thyagonevessilvestre12483 жыл бұрын
Saved my day, thanks.
@lyawileh.a87414 жыл бұрын
Good explanation, thanks very much.
@snailedlt4 жыл бұрын
How can I combine this with the bottom navigation bar template, to get a swipeable view containing fragments?
@milomathew52673 жыл бұрын
i guess Im pretty randomly asking but does anybody know of a good place to stream newly released movies online ?
@dominikmagnus50743 жыл бұрын
@Milo Mathew I watch on FlixZone. You can find it by googling :)
@indignocat Жыл бұрын
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 } }
@rehansyed898 ай бұрын
What is ItemViewpagerBinding?
@indignocat8 ай бұрын
@@rehansyed89 It's the viewBinding class created for the binding if you've enabled viewBinding in build.gradle
@Dcutz4 жыл бұрын
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?
@claudiuhaidu34532 жыл бұрын
How do you get the image view without findViewById() at 08:39, you call holder.itemVIew.ivImage directly ?!?!
@ahappyperson65306 ай бұрын
use viewBinding bro, findByView is old so dont use it, direct use of ivImage is deprecated so use viewBinding
@shohruhpulatov86163 жыл бұрын
Thanks, very helpful!
@bhupeshpattanaik71503 жыл бұрын
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
@abostef774 жыл бұрын
thanks for the video description implementaion :)
@relaxtime65562 жыл бұрын
Nice, can plz share a way to use view binding in pager adapter? Thanks
@adolfochavez20214 жыл бұрын
Thanks bro, it helped me a lot
@PhilippLackner4 жыл бұрын
You're welcome!
@MCA_HimanshuSeth4 жыл бұрын
Mind blowing 😎
@jinayshah798 Жыл бұрын
Can anyone please explain the functioning of fakeDrag, like what happens while implementing it?
@Luffy_2804 Жыл бұрын
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
@MohammadPourmami4 жыл бұрын
Great ! It was very useful to mr
@siddharthaghosal21464 жыл бұрын
Thank you for the great content and explanation. It worked! :-D
@PhilippLackner4 жыл бұрын
You're welcome!
@henriquepetters4 жыл бұрын
Yo, dude! Great videos, glad i found you. Do you have some material on tablayout and fragments? Thanks for the great videos!
@PhilippLackner4 жыл бұрын
Thanks man, yes I do! Take a look in this fundamentals Playlist, I have a separate video on each of those
@jude-l3f4 жыл бұрын
You're awesome 👌
@PhilippLackner4 жыл бұрын
You too!
@themessias4 жыл бұрын
Great tutorial!, it is possible to preview of the image on both the left and the right? thanks!
@ravisoni-ck8oo3 жыл бұрын
Thanks for making video
@bryanguerra70944 жыл бұрын
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.
@ImaTheSeller-3 жыл бұрын
Does this viewpager2 works similary with a BarLayout as the old Viewpager??
@alexissuarezalvarez56222 жыл бұрын
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?
@sabirfitvlogs14082 жыл бұрын
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.
@kirbi88644 жыл бұрын
How 2 swipe activities to left/right like overlapped game cards and with slight arc trajectory ?
@valarmorghulisx4 жыл бұрын
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.
@PhilippLackner4 жыл бұрын
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
@PhilippLackner4 жыл бұрын
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
@TheImaginativeSachin2 жыл бұрын
@@PhilippLackner interesting
@brucewayne79094 жыл бұрын
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 :-)
@humbleson72374 жыл бұрын
try using small size images, big size images often leads to buffer that leads to slowing up performance
@os4_official2 жыл бұрын
Thanks, bro
@manishpingale65584 жыл бұрын
Sir, can we just use horizontal Recycler view instead of using viewpager?
@PhilippLackner4 жыл бұрын
Then you don't have the swiping functionality, instead you can scroll
@manishpingale65584 жыл бұрын
@@PhilippLackner ohh yeah got it 👍👍👍👍 thank you 🙏🙏🙏🙏🤗🤗🤗 great content watching your all series. 🤗
@starlite50974 жыл бұрын
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
@starlite50974 жыл бұрын
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
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!
@aryanvikash19674 жыл бұрын
No .. It's not a viewpager it just a another recyclerview 🤪😂 Great tutorial 🔥🔥
@norulesprateek4 жыл бұрын
It's ViewPager2*
@olatosin37034 жыл бұрын
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.
@PhilippLackner4 жыл бұрын
There is a function for viewpager called scrollToPosition which will do what the name says :D
@olatosin37034 жыл бұрын
@@PhilippLackner Oh ok.. I'll check it out. Thank you
@marwaeltayeb2 жыл бұрын
@@PhilippLackner This method scrollToPosition is not found. Can you help?
@Aleinux4 жыл бұрын
And if I want an auto slideshow and infinite loop? How I have to do? Thanks
@PhilippLackner4 жыл бұрын
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)
@ASININEMedia4 жыл бұрын
Hi, I tried to add dot indicator using TabsLayout and TabLayoutMediator. but its not showing Can you help me
@frozen10933 жыл бұрын
seems cool man
@gabrielvisiedopelaez21133 жыл бұрын
How I can load the images using Glide? is it posible in this example?
@ruturajghumkar2 жыл бұрын
Hello thanks for this tutorial it would be great if you provide the code of every tutorial !!
@ayushsinha48153 жыл бұрын
How to add both horizontal and vertical swapping in view pager 2
@RockoShaw4 жыл бұрын
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
@PhilippLackner4 жыл бұрын
You can clearly see the kotlin icon in the video thumbnail
@davidc4155 Жыл бұрын
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
@sergheiN Жыл бұрын
findViewById(R.id.viewPager).adapter = adapter
@sergheiN Жыл бұрын
as far I understand, author uses some plugin for Android Studio and that's why he can access identifiers in a such way 🙂
@coc3629 Жыл бұрын
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.....
@Luffy_2804 Жыл бұрын
how's journey going bro ? developed some apps or not ?
@ezequieladrianminniti62524 жыл бұрын
i was wondering why from nothing switched to kotlin
@javidsattar2814 жыл бұрын
How can we use several different fragments?
@mustafakorkmaz57024 жыл бұрын
Since kotlin-android-extenstions are deprecated, I couldn't do the holder.itemView.ivImage.setImageResource(curImage) part. Any suggestions for how to do it?
@PhilippLackner4 жыл бұрын
ViewBinding
@mustafakorkmaz57024 жыл бұрын
@@PhilippLackner Thanks I'm trying to learn ViewBinding
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 } }
@denisk38524 жыл бұрын
How to implement an infinity swiper?
@mlktech15314 жыл бұрын
Hi how can i go from right to letf
@VarunPrasadoneplusone Жыл бұрын
Please add dependency in description
@Luffy_2804 Жыл бұрын
no need dude , now we can implement it in xml directly
@maasiliy20024 жыл бұрын
How use two or more ViewPager?
@madhan68164 жыл бұрын
how to add buttons on viewpager. ex like btn.
@mohameddarwish13474 жыл бұрын
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
@harshitsrivastava99034 жыл бұрын
Thanks a lot
@jovianswank3003 жыл бұрын
what about cardview ????
@wesleytany.s32474 жыл бұрын
Can someone help D: the $kotlin_version does not work and does not sync at all
@bivinoc38044 жыл бұрын
How to find last swipe in viewpager 2 ?
@PhilippLackner4 жыл бұрын
just save the swipes and then check accordingly
@arpitgupta31514 жыл бұрын
My app is crashing after swiping last image
@1noob3693 жыл бұрын
Where is the code Bro!
@NickMirambeau3 жыл бұрын
**spends all night translating this into java somehow**