Drag and drop Reorder in Recycler View | Android

Поделиться
HTML-код
  • Опубликовано: 3 окт 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

  • @НаталіяРезнік-я8х
    @НаталіяРезнік-я8х 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.

  • @王小倫-r1i
    @王小倫-r1i 3 года назад +1

    thanks for your simple and clear tutorial!!

  • @waddahmustafa2954
    @waddahmustafa2954 3 года назад +1

    Wow man this is simple and works as magic. Thanks

  • @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 ?

  • @gamelogger5233
    @gamelogger5233 3 года назад +1

    thank you for this short and very useful vidoe

  • @RandomGuy-df1oy
    @RandomGuy-df1oy 3 года назад +1

    Great explanation mate

  • @AmitJayant
    @AmitJayant 4 года назад +1

    5:14 Pressure cooker :D

  • @afterhelloworld4476
    @afterhelloworld4476 4 года назад +1

    Great video. Explained everything to the point. Thanks

  • @yongkymartindo3343
    @yongkymartindo3343 3 года назад

    still relevant in 2021 thanks..

    • @yongkymartindo3343
      @yongkymartindo3343 3 года назад

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

  • @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 5 лет назад +1

    best tutorials ever

  • @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.
      ruclips.net/p/PLdHg5T0SNpN3CMNtsd5KGaiBtzhTGIwtC

    • @ejazrahim6349
      @ejazrahim6349 4 года назад

      @@mafiacodes ok sir plz do on broadcasts

  • @internettime9309
    @internettime9309 4 года назад +1

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

  • @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

  • @d-news4076
    @d-news4076 2 года назад

    Thank you, helped!

  • @vinitgrover360
    @vinitgrover360 Год назад +1

    Thanks

  • @DoubleNation
    @DoubleNation 4 года назад +1

    Really nice tutorial, you got a new sub!

  • @Julian-rx1ob
    @Julian-rx1ob 4 года назад +1

    great tutorial! ty so much dude:)

  • @WesleyFranks
    @WesleyFranks 4 года назад +1

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

  • @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?

  • @cancihancelebi3495
    @cancihancelebi3495 3 года назад +1

    Thank you, how will the settings stay?

  • @Dhruvbala
    @Dhruvbala 4 года назад +2

    Nice pressure cooker

  • @dimitrikravtsov4798
    @dimitrikravtsov4798 2 года назад +1

    Really helpful!

  • @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

  • @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?

  • @intelligentcoding689
    @intelligentcoding689 3 года назад

    Very helpful, thanks

  • @demstheprogrammer
    @demstheprogrammer 8 месяцев назад

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

  • @empiregood9225
    @empiregood9225 2 года назад

    And SharefPreference in Drag in Drog of the RecyclerView?

  • @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

  • @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.

  • @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.

  • @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.

  • @LaOdeMuhArmadiAM
    @LaOdeMuhArmadiAM 4 года назад +1

    it's running in my app

  • @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 ruclips.net/video/VtnLpHUu2U0/видео.html
      OR
      depending on the row you can change the button title dynamically.
      Subscribe like share😊

  • @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.

  • @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!

  • @lglf77
    @lglf77 2 года назад

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

  • @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 :(

  • @pronavsandhu
    @pronavsandhu 4 года назад

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

  • @kauanmatos1632
    @kauanmatos1632 3 года назад +2

    Portuguese legends, please!!!

  • @yrrag
    @yrrag 4 года назад +1

    Awesome!

  • @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.

  • @은혜-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?

  • @jeet198
    @jeet198 3 года назад

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

  • @analogsound
    @analogsound 3 года назад

    You have a good keyboard :-)

  • @giddyshow6718
    @giddyshow6718 Год назад

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

  • @LaOdeMuhArmadiAM
    @LaOdeMuhArmadiAM 4 года назад +1

    Thank's brother

  • @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?

  • @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 5 лет назад

    im dying with that noise :v

  • @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?

  • @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

  • @mehulpanchal7539
    @mehulpanchal7539 4 года назад +1

    TYSOOM :)

    • @mafiacodes
      @mafiacodes  4 года назад +1

      subscribe like share....

  • @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?

  • @Iraqistudent
    @Iraqistudent 2 года назад

    🌹🌹🌹

  • @mohammedalsadoon8444
    @mohammedalsadoon8444 2 года назад +1

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