CREATING SWIPABLE VIEWS WITH VIEWPAGER 2 - Android Fundamentals

  Рет қаралды 68,630

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 131
@kopilkaiser8991
@kopilkaiser8991 Жыл бұрын
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
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks a lot, you're welcome🙏
@abostef77
@abostef77 4 жыл бұрын
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.
@iftak01
@iftak01 4 жыл бұрын
your the best man!! your just the best... Kotlin + all the new Android libraries....bless you!
@daiyrkanybekov8575
@daiyrkanybekov8575 4 жыл бұрын
Great Tutorial! Hello from Bishkek, Kyrgyzstan
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Awesome! Thank you!
@Diego17511
@Diego17511 3 жыл бұрын
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
@starlite5097
@starlite5097 4 жыл бұрын
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.
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks a lot for your support, glad my content helps you!!
@theodordimov6518
@theodordimov6518 Жыл бұрын
Great tutorial. I think you might be missing a `viewPager = findViewById` instruction at around 9:52
@mandalsalman
@mandalsalman 4 жыл бұрын
Impressive. You make look everything super easy.
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks! :)
@PrashantKumar-je4bs
@PrashantKumar-je4bs 2 жыл бұрын
at 9:48 instead of using viewPager.adepter use this. findViewById(R.id.viewPager).adapter = adepter This will work....
@Et_tu
@Et_tu 2 жыл бұрын
it helped, love u man
@spencerdamon1248
@spencerdamon1248 Жыл бұрын
Thank you, your input is greatly appreciated!
@dirajnaik9869
@dirajnaik9869 Жыл бұрын
thanks bro for ViewPager2
@norulesprateek
@norulesprateek 4 жыл бұрын
Thought this would be very complex. Thanks a lot for making this easy.
@Indently
@Indently 4 жыл бұрын
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? :)
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Hey man, thanks! If you want to interact with the items you can do that in the RecyclerView adapter in onBindViewHolder
@teunstout6725
@teunstout6725 4 жыл бұрын
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
@shareemteofilo6257
@shareemteofilo6257 3 жыл бұрын
Thank you so much. This helped me a lot to understand view pager.
@mario33067
@mario33067 4 жыл бұрын
this is an awesome channel! thks so much for every tutorial videos! it's helping a lot!
@PhilippLackner
@PhilippLackner 4 жыл бұрын
You're very welcome!
@GriNAME
@GriNAME 2 жыл бұрын
Thank you so much!!! Quickly and easy :)
@nousernamethx
@nousernamethx 3 жыл бұрын
Thank you, worked like a charm!
@PrashantKumar-je4bs
@PrashantKumar-je4bs 2 жыл бұрын
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.
@emmanuelsawe976
@emmanuelsawe976 2 жыл бұрын
Same problem here.
@dirajnaik9869
@dirajnaik9869 Жыл бұрын
findViewById(R.id.viewPager).adapter=adapter
@ahappyperson6530
@ahappyperson6530 6 ай бұрын
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
@manishpingale6558
@manishpingale6558 4 жыл бұрын
So glad that you use DARK THEME!!!!!!!!!!!!!!!!
@kevinbuguecio5673
@kevinbuguecio5673 4 жыл бұрын
It really helped me mate, thanks!
@thyagonevessilvestre1248
@thyagonevessilvestre1248 3 жыл бұрын
Saved my day, thanks.
@lyawileh.a8741
@lyawileh.a8741 4 жыл бұрын
Good explanation, thanks very much.
@snailedlt
@snailedlt 4 жыл бұрын
How can I combine this with the bottom navigation bar template, to get a swipeable view containing fragments?
@milomathew5267
@milomathew5267 3 жыл бұрын
i guess Im pretty randomly asking but does anybody know of a good place to stream newly released movies online ?
@dominikmagnus5074
@dominikmagnus5074 3 жыл бұрын
@Milo Mathew I watch on FlixZone. You can find it by googling :)
@indignocat
@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 } }
@rehansyed89
@rehansyed89 8 ай бұрын
What is ItemViewpagerBinding?
@indignocat
@indignocat 8 ай бұрын
@@rehansyed89 It's the viewBinding class created for the binding if you've enabled viewBinding in build.gradle
@Dcutz
@Dcutz 4 жыл бұрын
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?
@claudiuhaidu3453
@claudiuhaidu3453 2 жыл бұрын
How do you get the image view without findViewById() at 08:39, you call holder.itemVIew.ivImage directly ?!?!
@ahappyperson6530
@ahappyperson6530 6 ай бұрын
use viewBinding bro, findByView is old so dont use it, direct use of ivImage is deprecated so use viewBinding
@shohruhpulatov8616
@shohruhpulatov8616 3 жыл бұрын
Thanks, very helpful!
@bhupeshpattanaik7150
@bhupeshpattanaik7150 3 жыл бұрын
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
@abostef77
@abostef77 4 жыл бұрын
thanks for the video description implementaion :)
@relaxtime6556
@relaxtime6556 2 жыл бұрын
Nice, can plz share a way to use view binding in pager adapter? Thanks
@adolfochavez2021
@adolfochavez2021 4 жыл бұрын
Thanks bro, it helped me a lot
@PhilippLackner
@PhilippLackner 4 жыл бұрын
You're welcome!
@MCA_HimanshuSeth
@MCA_HimanshuSeth 4 жыл бұрын
Mind blowing 😎
@jinayshah798
@jinayshah798 Жыл бұрын
Can anyone please explain the functioning of fakeDrag, like what happens while implementing it?
@Luffy_2804
@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
@MohammadPourmami
@MohammadPourmami 4 жыл бұрын
Great ! It was very useful to mr
@siddharthaghosal2146
@siddharthaghosal2146 4 жыл бұрын
Thank you for the great content and explanation. It worked! :-D
@PhilippLackner
@PhilippLackner 4 жыл бұрын
You're welcome!
@henriquepetters
@henriquepetters 4 жыл бұрын
Yo, dude! Great videos, glad i found you. Do you have some material on tablayout and fragments? Thanks for the great videos!
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks man, yes I do! Take a look in this fundamentals Playlist, I have a separate video on each of those
@jude-l3f
@jude-l3f 4 жыл бұрын
You're awesome 👌
@PhilippLackner
@PhilippLackner 4 жыл бұрын
You too!
@themessias
@themessias 4 жыл бұрын
Great tutorial!, it is possible to preview of the image on both the left and the right? thanks!
@ravisoni-ck8oo
@ravisoni-ck8oo 3 жыл бұрын
Thanks for making video
@bryanguerra7094
@bryanguerra7094 4 жыл бұрын
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-
@ImaTheSeller- 3 жыл бұрын
Does this viewpager2 works similary with a BarLayout as the old Viewpager??
@alexissuarezalvarez5622
@alexissuarezalvarez5622 2 жыл бұрын
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?
@sabirfitvlogs1408
@sabirfitvlogs1408 2 жыл бұрын
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.
@kirbi8864
@kirbi8864 4 жыл бұрын
How 2 swipe activities to left/right like overlapped game cards and with slight arc trajectory ?
@valarmorghulisx
@valarmorghulisx 4 жыл бұрын
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.
@PhilippLackner
@PhilippLackner 4 жыл бұрын
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
@PhilippLackner 4 жыл бұрын
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
@TheImaginativeSachin
@TheImaginativeSachin 2 жыл бұрын
@@PhilippLackner interesting
@brucewayne7909
@brucewayne7909 4 жыл бұрын
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 :-)
@humbleson7237
@humbleson7237 4 жыл бұрын
try using small size images, big size images often leads to buffer that leads to slowing up performance
@os4_official
@os4_official 2 жыл бұрын
Thanks, bro
@manishpingale6558
@manishpingale6558 4 жыл бұрын
Sir, can we just use horizontal Recycler view instead of using viewpager?
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Then you don't have the swiping functionality, instead you can scroll
@manishpingale6558
@manishpingale6558 4 жыл бұрын
@@PhilippLackner ohh yeah got it 👍👍👍👍 thank you 🙏🙏🙏🙏🤗🤗🤗 great content watching your all series. 🤗
@starlite5097
@starlite5097 4 жыл бұрын
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
@starlite5097
@starlite5097 4 жыл бұрын
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
@rabiakhalid2158
@rabiakhalid2158 Жыл бұрын
Can we these images from right to left?
@jdurefaccini
@jdurefaccini 4 жыл бұрын
implementation 'com.google.android.material:material:1.3.0-beta01'
@dakopyc
@dakopyc Жыл бұрын
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!
@aryanvikash1967
@aryanvikash1967 4 жыл бұрын
No .. It's not a viewpager it just a another recyclerview 🤪😂 Great tutorial 🔥🔥
@norulesprateek
@norulesprateek 4 жыл бұрын
It's ViewPager2*
@olatosin3703
@olatosin3703 4 жыл бұрын
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.
@PhilippLackner
@PhilippLackner 4 жыл бұрын
There is a function for viewpager called scrollToPosition which will do what the name says :D
@olatosin3703
@olatosin3703 4 жыл бұрын
@@PhilippLackner Oh ok.. I'll check it out. Thank you
@marwaeltayeb
@marwaeltayeb 2 жыл бұрын
@@PhilippLackner This method scrollToPosition is not found. Can you help?
@Aleinux
@Aleinux 4 жыл бұрын
And if I want an auto slideshow and infinite loop? How I have to do? Thanks
@PhilippLackner
@PhilippLackner 4 жыл бұрын
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)
@ASININEMedia
@ASININEMedia 4 жыл бұрын
Hi, I tried to add dot indicator using TabsLayout and TabLayoutMediator. but its not showing Can you help me
@frozen1093
@frozen1093 3 жыл бұрын
seems cool man
@gabrielvisiedopelaez2113
@gabrielvisiedopelaez2113 3 жыл бұрын
How I can load the images using Glide? is it posible in this example?
@ruturajghumkar
@ruturajghumkar 2 жыл бұрын
Hello thanks for this tutorial it would be great if you provide the code of every tutorial !!
@ayushsinha4815
@ayushsinha4815 3 жыл бұрын
How to add both horizontal and vertical swapping in view pager 2
@RockoShaw
@RockoShaw 4 жыл бұрын
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
@PhilippLackner
@PhilippLackner 4 жыл бұрын
You can clearly see the kotlin icon in the video thumbnail
@davidc4155
@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
@sergheiN Жыл бұрын
findViewById(R.id.viewPager).adapter = adapter
@sergheiN
@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
@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
@Luffy_2804 Жыл бұрын
how's journey going bro ? developed some apps or not ?
@ezequieladrianminniti6252
@ezequieladrianminniti6252 4 жыл бұрын
i was wondering why from nothing switched to kotlin
@javidsattar281
@javidsattar281 4 жыл бұрын
How can we use several different fragments?
@mustafakorkmaz5702
@mustafakorkmaz5702 4 жыл бұрын
Since kotlin-android-extenstions are deprecated, I couldn't do the holder.itemView.ivImage.setImageResource(curImage) part. Any suggestions for how to do it?
@PhilippLackner
@PhilippLackner 4 жыл бұрын
ViewBinding
@mustafakorkmaz5702
@mustafakorkmaz5702 4 жыл бұрын
@@PhilippLackner Thanks I'm trying to learn ViewBinding
@berkayozgen259
@berkayozgen259 3 жыл бұрын
@@mustafakorkmaz5702 Merhaba kardeşim, çözüm bulabildin mi?
@mustafakorkmaz5702
@mustafakorkmaz5702 3 жыл бұрын
@@berkayozgen259 bulamadım maalesef
@indignocat
@indignocat Жыл бұрын
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 } }
@denisk3852
@denisk3852 4 жыл бұрын
How to implement an infinity swiper?
@mlktech1531
@mlktech1531 4 жыл бұрын
Hi how can i go from right to letf
@VarunPrasadoneplusone
@VarunPrasadoneplusone Жыл бұрын
Please add dependency in description
@Luffy_2804
@Luffy_2804 Жыл бұрын
no need dude , now we can implement it in xml directly
@maasiliy2002
@maasiliy2002 4 жыл бұрын
How use two or more ViewPager?
@madhan6816
@madhan6816 4 жыл бұрын
how to add buttons on viewpager. ex like btn.
@mohameddarwish1347
@mohameddarwish1347 4 жыл бұрын
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
@harshitsrivastava9903
@harshitsrivastava9903 4 жыл бұрын
Thanks a lot
@jovianswank300
@jovianswank300 3 жыл бұрын
what about cardview ????
@wesleytany.s3247
@wesleytany.s3247 4 жыл бұрын
Can someone help D: the $kotlin_version does not work and does not sync at all
@bivinoc3804
@bivinoc3804 4 жыл бұрын
How to find last swipe in viewpager 2 ?
@PhilippLackner
@PhilippLackner 4 жыл бұрын
just save the swipes and then check accordingly
@arpitgupta3151
@arpitgupta3151 4 жыл бұрын
My app is crashing after swiping last image
@1noob369
@1noob369 3 жыл бұрын
Where is the code Bro!
@NickMirambeau
@NickMirambeau 3 жыл бұрын
**spends all night translating this into java somehow**
@PhilippLackner
@PhilippLackner 3 жыл бұрын
in that time you could've learned kotlin
@TheImaginativeSachin
@TheImaginativeSachin 2 жыл бұрын
@@PhilippLackner lol
@DilpreetSingh-pd6co
@DilpreetSingh-pd6co 3 жыл бұрын
plzz upload with java
@PhilippLackner
@PhilippLackner 3 жыл бұрын
plzzz learn with kotlin
TAB LAYOUT WITH VIEWPAGER 2 - Android Fundamentals
11:26
Philipp Lackner
Рет қаралды 42 М.
RECYCLERVIEW - Android Fundamentals
24:58
Philipp Lackner
Рет қаралды 107 М.
«Жат бауыр» телехикаясы І 30 - бөлім | Соңғы бөлім
52:59
Qazaqstan TV / Қазақстан Ұлттық Арнасы
Рет қаралды 340 М.
Who is More Stupid? #tiktok #sigmagirl #funny
0:27
CRAZY GREAPA
Рет қаралды 10 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Putting the E in ESM
1:44:57
Seve
Рет қаралды 67
I Helped 2,000 People Walk Again
15:31
MrBeast
Рет қаралды 12 МЛН
INTENTS AND STARTING ACTIVITIES - Android Fundamentals
16:11
Philipp Lackner
Рет қаралды 70 М.
BOTTOM NAVIGATION VIEW - Android Fundamentals
16:53
Philipp Lackner
Рет қаралды 56 М.
Mock Junior Android Developer Interview
1:22:18
DevGym
Рет қаралды 1,7 М.
ALERT DIALOG - Android Fundamentals
18:47
Philipp Lackner
Рет қаралды 28 М.
RecyclerView | Everything You Need to Know
25:07
Practical Coding
Рет қаралды 149 М.
TOOLBAR MENUS - Android Fundamentals
11:48
Philipp Lackner
Рет қаралды 36 М.
FRAGMENTS - Android Fundamentals
17:29
Philipp Lackner
Рет қаралды 340 М.