Drag and drop Reorder in Recycler View | Android

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ก.ย. 2024
  • In this video you will learn how to handle #drag and drop reordering inside a recycler view.
    ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for 6 months and I love it! www.kite.com/g...
    FREE $100 credit @Digital Ocean: m.do.co/c/3208...
    Patreon: / trulymittal
    Subscribe: www.youtube.co...
    #RecyclerView (Basic Setup): • Recycler View with com...
    Pull to Refresh Recycler View: • Pull to Refresh in Rec...
    Swipe gestures Recycler View: • Swipe gestures in Recy...
    Github(Tutorial): github.com/tru...
    RecyclerView: developer.andr...
    RecyclerView(dependency): developer.andr...
    ---------------
    More useful videos
    ---------------
    #ViewModel: • View Model | Live Data...
    #Retrofit: • RETROFIT Tutorial (v 2...
    #WorkManager: • Work Manager | Android...
    #KeyframeAnimations: • Keyframe Animations wi...
    #CollapsingToolbar Layout: • Collapsing Toolbar Lay...
    #BottomNavigation View: • Bottom Navigation View...
    #NavigationComponent: • Navigation Component |...
    #NightMode: • Night Mode | Dark Mode...
    #ButterKnife: • Butter Knife | Field a...
    SplashScreen: • Splash screen | Launch...
    Singletons: • Singletons | What When...
    ---------------
    What I use
    ---------------
    Mouse: amzn.to/2O9RJtu
    Keyboard: amzn.to/2qxajCU
    Keyboard 2: amzn.to/2XDWH4X
    Monitor: amzn.to/2pDg7dH
    Processor: amzn.to/347WWIb
    RAM: amzn.to/2QEkUqw
    Graphics: amzn.to/33aBrF4
    Microphone: amzn.to/2DabdI9
    #yoursTruly #tutorial #how-to #android

ความคิดเห็น • 111

  • @user-qp2mx3hy5g
    @user-qp2mx3hy5g 4 ปีที่แล้ว +12

    Thanks a lot! Short, simple, working and exactly what I was searching for.

  • @mohammadnoorhossain126
    @mohammadnoorhossain126 ปีที่แล้ว +1

    Thanks a lot! Short, simple, working and exactly what I was searching And Struggle For eight hours !

  • @somechazz_y
    @somechazz_y 4 ปีที่แล้ว +7

    man, this was such a nice thorough explanation, thanks a lot, you have me curious about the source of that noise tho lol

    • @alfredzr
      @alfredzr ปีที่แล้ว

      Pressure cooker lol. A common vessel in Indian cooking. Goes to show he made this tutorial while waiting for his rice or curry to cook

  • @manashharshvardhan5007
    @manashharshvardhan5007 3 ปีที่แล้ว +2

    Mogambo khush hua...😎
    Aur apoko 1 new subscriber mil gya

  • @samstoyroom
    @samstoyroom 4 ปีที่แล้ว +4

    Amazing tutorial, just what I need! Thank you so much.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share 😊

  • @hissabis2068
    @hissabis2068 3 ปีที่แล้ว +2

    Thank you so much bro, you do a great job. I follow you continuously.

  • @AmitJayant
    @AmitJayant 4 ปีที่แล้ว +1

    5:14 Pressure cooker :D

  • @user-ni9cn2ff9o
    @user-ni9cn2ff9o 3 ปีที่แล้ว +1

    thanks for your simple and clear tutorial!!

  • @sourcecode6467
    @sourcecode6467 3 ปีที่แล้ว +1

    Excellent tutorial, very well explained and demonstrated. Thanks. Love from England ❤️

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Subscribe like share

    • @sourcecode6467
      @sourcecode6467 3 ปีที่แล้ว

      @@mafiacodes I liked and subscribed, I don't have anyone to share too 😂

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      😅

    • @sourcecode6467
      @sourcecode6467 3 ปีที่แล้ว

      @@mafiacodes are all of your Android tutorials in Java ? Have you shifted to Kotlin ?

  • @waddahmustafa2954
    @waddahmustafa2954 3 ปีที่แล้ว +1

    Wow man this is simple and works as magic. Thanks

  • @gamelogger5233
    @gamelogger5233 2 ปีที่แล้ว +1

    thank you for this short and very useful vidoe

  • @RandomGuy-df1oy
    @RandomGuy-df1oy 3 ปีที่แล้ว +1

    Great explanation mate

  • @afterhelloworld4476
    @afterhelloworld4476 4 ปีที่แล้ว +1

    Great video. Explained everything to the point. Thanks

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share

  • @yongkymartindo3343
    @yongkymartindo3343 3 ปีที่แล้ว

    still relevant in 2021 thanks..

    • @yongkymartindo3343
      @yongkymartindo3343 3 ปีที่แล้ว

      but, how to get latest position of all array, after rearange the playlist ?

  • @ejazrahim6349
    @ejazrahim6349 4 ปีที่แล้ว +1

    sir u have the one of the best android lectrs, i have seen your recyclerview and it was somuch easy to understand , kindly expain data base and broadcast recievers plz
    thanks

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Thanks, I have a playlist for Room Database, you can watch that.
      th-cam.com/play/PLdHg5T0SNpN3CMNtsd5KGaiBtzhTGIwtC.html

    • @ejazrahim6349
      @ejazrahim6349 4 ปีที่แล้ว

      @@mafiacodes ok sir plz do on broadcasts

  • @vinitgrover360
    @vinitgrover360 ปีที่แล้ว +1

    Thanks

  • @internettime9309
    @internettime9309 4 ปีที่แล้ว +1

    Thanks for the help but how to change the position in database as well?

  • @luiizfiilhoo
    @luiizfiilhoo 4 ปีที่แล้ว +1

    Thank you bro, thats exactly what i need.

  • @georgeanderson9625
    @georgeanderson9625 4 ปีที่แล้ว +1

    Thank you very much for this tutorial.

  • @jagadishlakkur191
    @jagadishlakkur191 4 ปีที่แล้ว +1

    best tutorials ever

  • @tresormvumbi
    @tresormvumbi 4 ปีที่แล้ว +1

    Thanks a lot dude for this nice tutorial, it worked great!

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share😊

  • @starship9874
    @starship9874 4 ปีที่แล้ว +1

    Awesome tutorial

  • @Dhruvbala
    @Dhruvbala 4 ปีที่แล้ว +2

    Nice pressure cooker

  • @lglf77
    @lglf77 3 ปีที่แล้ว +1

    Congratulations on the content, but if I quit sort a list down, if I quit the activity, is the reordering saved? I don't think so, I never see these videos in their entirety. What to do to try to follow your channel, will you complete the rest of the video?

  • @d-news4076
    @d-news4076 2 ปีที่แล้ว

    Thank you, helped!

  • @DoubleNation
    @DoubleNation 4 ปีที่แล้ว +1

    Really nice tutorial, you got a new sub!

  • @user-et6vx6ri5h
    @user-et6vx6ri5h ปีที่แล้ว +1

    thx

  • @dimitrikravtsov4798
    @dimitrikravtsov4798 2 ปีที่แล้ว +1

    Really helpful!

  • @intelligentcoding689
    @intelligentcoding689 3 ปีที่แล้ว

    Very helpful, thanks

  • @WesleyFranks
    @WesleyFranks 4 ปีที่แล้ว +1

    can you do a video on this, but change the background color of the item that is being dragged?

  • @cancihancelebi3495
    @cancihancelebi3495 3 ปีที่แล้ว +1

    Thank you, how will the settings stay?

  • @Julian-rx1ob
    @Julian-rx1ob 4 ปีที่แล้ว +1

    great tutorial! ty so much dude:)

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share

  • @demstheprogrammer
    @demstheprogrammer 7 หลายเดือนก่อน

    but how to make is automatically changed the index after the swap

  • @itsgauravparmar
    @itsgauravparmar 2 ปีที่แล้ว +1

    @yourtruly there is a position like 0,1,2,3,4,5 on the listing. Can you suggest to me how I can update that position as well?

  • @empiregood9225
    @empiregood9225 2 ปีที่แล้ว

    And SharefPreference in Drag in Drog of the RecyclerView?

  • @sorinaion1365
    @sorinaion1365 4 ปีที่แล้ว +1

    Really great tutorial ! Thank you !
    One question please - in the onMove method, the return value was "false". Why ?
    I tried to replase the "false" to "true", but nothing changed in the functionality.
    What is the purpose of that boolean "return" value, since nothing is changed based on that value ?
    Thank you !

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +2

      You should return TRUE, its like telling the touch helper that the move was handled.

  • @menahemamar4491
    @menahemamar4491 ปีที่แล้ว

    The SWAP operation is not correct. Let's say I have a list of 3 elements [A,B,C] and the user moved the item from position 2 (C) to position 0 very quickly that the onMove() method was called *only once* when fromPosition=2 and toPosition=0 (It happened to me) then the updated list should be [C,A,B] and not [C,B,A] as the SWAP operation does

  • @guidobertelli7337
    @guidobertelli7337 ปีที่แล้ว +1

    Hello, thanks for the great video but unfortunately it solved just an half of my problem. My recViews are connected to a realtime Firebase Database and I would like to implement the changes in position (swapping) also in the database so that those changes are then kind of permanent and they do not disappear when I exit the activity.
    Thanks in advance for your help and God bless u

    • @guidobertelli7337
      @guidobertelli7337 ปีที่แล้ว

      The order of keys that you see in the console is fixed. It's just the lexicographic (alphabetical) ordering of the keys. There is no "move" operation for child keys. If you want the children to be ordered, put some child value under each of them that you can use in a query to order them.

    • @mafiacodes
      @mafiacodes  ปีที่แล้ว

      Thank you, that you have to do manually by triggering a call to firebase api. Afaik.

    • @guidobertelli7337
      @guidobertelli7337 ปีที่แล้ว

      I found this answer on stackoverflow and it looks promising

  • @kauanmatos1632
    @kauanmatos1632 3 ปีที่แล้ว +2

    Portuguese legends, please!!!

  • @nikkieloves
    @nikkieloves 4 ปีที่แล้ว +1

    Fabulous tutorial! Is there a way to add unique buttons to each line of the recyclerview?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Probably you want is this Multi view RecyclerView | getItemViewType() | Android th-cam.com/video/VtnLpHUu2U0/w-d-xo.html
      OR
      depending on the row you can change the button title dynamically.
      Subscribe like share😊

  • @Info-dj7qs
    @Info-dj7qs 3 ปีที่แล้ว

    Sir , how i can change the color of view only for moving time and then back to normal.
    i have mini. target device is 19 so please give me solution.

  • @lglf77
    @lglf77 2 ปีที่แล้ว

    And SQLite record position of this RecyclerView, i not searching video in you tube? with use of the onLongClickListener?

  • @4ytonly
    @4ytonly 4 ปีที่แล้ว +1

    Is there a way to do this without long press, but just with touch and drag? I would like to insert an image, a handle so user can touch on that handle and drag instead of touch and hold for drag?

    • @martinh3729
      @martinh3729 4 ปีที่แล้ว

      I'm looking for this as well. Other options seem rather complicated.

  • @SumitSingh-df7gg
    @SumitSingh-df7gg ปีที่แล้ว

    Can you please help , in Drag and Drop for child items having different sizes.
    I am using StaggeredGridLayoutManager.
    Drag and Drop is working fine. But during Drag of Big items leads to Items duplication in RecyclerView background.

  • @jatinchopra1621
    @jatinchopra1621 4 ปีที่แล้ว +2

    Why does my RecyclerView with ItemTouchHelper stop dragging after only one item

    • @jatinchopra1621
      @jatinchopra1621 4 ปีที่แล้ว +3

      i fixed it by deleting this method in my recycle view adapter
      @Override
      public int getItemViewType(int position)
      {
      return position;
      }

    • @Devlyashov
      @Devlyashov 4 ปีที่แล้ว +1

      @@jatinchopra1621 Man, you are awesome!
      I solving this problem for more than two days and only you helped me!
      Thank you very much!

  • @은혜-s8z
    @은혜-s8z ปีที่แล้ว

    hi i am getting error " java.lang.IndexOutOfBoundsException: Index: 5, Size: 0" on collections.swap. my data is from firestore. can u help me?

  • @yrrag
    @yrrag 4 ปีที่แล้ว +1

    Awesome!

  • @vijay6877
    @vijay6877 4 ปีที่แล้ว

    Your video is helped me in achieving the functionality but I want you to please explain a bit more about the classess you use. I mean I don't know what is item touch helper is and how can I modify it according to my convenience.
    PS: Sorry for the grammatical mistakes.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      I'll try to make a video for the same sometime sooner.

  • @giddyshow6718
    @giddyshow6718 ปีที่แล้ว

    *Как мне двигать кнопки в LinearLayout?*

  • @LaOdeMuhArmadiAM
    @LaOdeMuhArmadiAM 4 ปีที่แล้ว +1

    Thank's brother

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share

  • @pronavsandhu
    @pronavsandhu 4 ปีที่แล้ว

    very nice bro, can you please tell me if you know how to drag an item into folder?

  • @hemantpatel5118
    @hemantpatel5118 3 ปีที่แล้ว

    great man! ❤
    but I want to drag and drop by touch any button of recyclerview item instead of Long press .
    please help :(

  • @analogsound
    @analogsound 3 ปีที่แล้ว

    You have a good keyboard :-)

  • @jeet198
    @jeet198 3 ปีที่แล้ว

    But After App close , items go to the initial position..
    How to solve this this?

  • @LaOdeMuhArmadiAM
    @LaOdeMuhArmadiAM 4 ปีที่แล้ว +1

    it's running in my app

  • @vamsi1871
    @vamsi1871 5 ปีที่แล้ว

    Plz teach me pagination adapter in recycler view

  • @jeet198
    @jeet198 3 ปีที่แล้ว

    Is it possible to save their position after changing order, even after closing the app remains same.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +2

      Need to create a field in ur db and then change sort order there after sortint

    • @jeet198
      @jeet198 3 ปีที่แล้ว

      @@mafiacodes can you make a video for that?

  • @mehulpanchal7539
    @mehulpanchal7539 4 ปีที่แล้ว +1

    TYSOOM :)

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      subscribe like share....

  • @algernonanon4533
    @algernonanon4533 4 ปีที่แล้ว

    is there a way to add a hide/unhide icon on drag view?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      Use on drag start drag end to hide and show

  • @michaelschroder7186
    @michaelschroder7186 4 ปีที่แล้ว

    Many thanks for the tutorial. I tried to follow your instructions. Unfortunately the drag and drop doesn't work. As soon as I click on the button longer, the entry is not moved but deleted. Do you have an idea what I am doing wrong?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Seems that u have added a long click listener on ur items and that I called before drag could work, if possible share ur code on github so I can see what’s happening

    • @michaelschroder7186
      @michaelschroder7186 4 ปีที่แล้ว

      @@mafiacodes I have tried to put put the Code to GIT. Hope you have access to my "MainActivity!" File.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Send me the link

    • @michaelschroder7186
      @michaelschroder7186 4 ปีที่แล้ว

      @@mafiacodes github.com/SoftwareBaschtler/recyclerView_V01.git

    • @michaelschroder7186
      @michaelschroder7186 4 ปีที่แล้ว

      @@mafiacodes Does the link work? Could you read the file?

  • @pranavpratapsingh6002
    @pranavpratapsingh6002 3 ปีที่แล้ว

    Sir, it is only working to rearranging names , if we use different icons for each movie(or other information) then this won't work for their icon(or other information) ,anyway i resolved it , but you should mention it in video too......anyway thanks...

    • @moazzahran313
      @moazzahran313 3 ปีที่แล้ว +1

      how did you resolve it?

    • @pranavpratapsingh6002
      @pranavpratapsingh6002 3 ปีที่แล้ว

      @@moazzahran313 in this tutorial they only took , list of name .If u are using with list of icons(or many extra things) then just use all the list along with name lists(like in swap function) ,I can more clear it , Watsapp me at 7897570695...if u are interested 😄

  • @denialfian2122
    @denialfian2122 4 ปีที่แล้ว

    im dying with that noise :v

  • @Iraqistudent
    @Iraqistudent 2 ปีที่แล้ว

    🌹🌹🌹

  • @luciarudiak5027
    @luciarudiak5027 4 ปีที่แล้ว

    How to capture fromPosition and id to post?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Watch @ 4:45 to know how to get from and to position

  • @vijaysathvikab5866
    @vijaysathvikab5866 4 ปีที่แล้ว

    how to do this for only card views

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      U mean without recycler view

    • @vijaysathvikab5866
      @vijaysathvikab5866 4 ปีที่แล้ว

      @@mafiacodes yes,Only for cardviews inside a fragment.Can we do it?if yes,please do a video

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      This method is for recycler view

    • @vijaysathvikab5866
      @vijaysathvikab5866 4 ปีที่แล้ว

      @@mafiacodes yes,but can we do it for card view only?

  • @mohammedalsadoon8444
    @mohammedalsadoon8444 2 ปีที่แล้ว +1

    Thanks a lot! Short, simple, working and exactly what I was searching for.