RecyclerView Item Click | Best Practice Way

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 108

  • @Krankschwester
    @Krankschwester 2 роки тому +23

    Finally someone who explains it properly and doesn't create 15 classes and interfaces for a click listener... Thanks😁

  • @Sydewinder890
    @Sydewinder890 2 роки тому +25

    Still a better explanation than my pre-recorded lecture that we have been using since 4 years ago

  • @fctvlthq
    @fctvlthq 2 роки тому +1

    Thank you! When stackoverflow doesnt help or only offers deprecated information... UA-cam helps! You are the best!

  • @rohitsinha1092
    @rohitsinha1092 11 місяців тому

    thanks man saves a ton of hassle and works like a charm truly helpful

  • @rydzu98
    @rydzu98 9 місяців тому

    thx bro, finally someone who can it simply explain

  • @evangelistar
    @evangelistar Рік тому +1

    Great video! Easy to understand. Thank you!

  • @AD-eb2wb
    @AD-eb2wb 3 місяці тому

    Best video for RecyclerView Item Click Forwarding by far!
    Question: why does the onClickListener in an adapter need to be placed in an init { } block to work, but in fragments and activities you don't need to do this?

  • @edgaralexis9738
    @edgaralexis9738 2 роки тому +1

    Excelent Explanation!!! Thank you so much. You're brilliant

  • @rungxanh2901
    @rungxanh2901 2 роки тому +2

    Thank you very much man! Efficient and easy to understand!

  • @pavolmotyl3232
    @pavolmotyl3232 2 роки тому +1

    Man, great video! Helped me so much. Thanks

  • @burakpmk
    @burakpmk 3 роки тому +1

    Thank u so much This video very help me with my university project

  • @SwainerGamer
    @SwainerGamer Рік тому

    You have helped me immensely thank you very much!

  • @AryanSingh-zv5ch
    @AryanSingh-zv5ch 2 роки тому

    Thanks man first video that really helped

  • @Anushkai1
    @Anushkai1 7 місяців тому

    Thank You. Good Explanation

  • @dimalag07
    @dimalag07 Рік тому +1

    pure gold! Thank you

  • @dasahead33
    @dasahead33 2 роки тому

    Great explanation. Worked for me

  • @stillpickinganame5350
    @stillpickinganame5350 Рік тому

    Great video as always!! Thank you man❤

  • @mohammedel6420
    @mohammedel6420 2 роки тому

    good content i understand the concept even don't work for me, but realy understand a lot

  • @andresmonagas7662
    @andresmonagas7662 3 роки тому +1

    Man, you make such good content!

  • @trndsttr7585
    @trndsttr7585 3 місяці тому

    Stellar work man.

  • @SimranKaur-fc4hn
    @SimranKaur-fc4hn 2 роки тому

    You've made it quite easy......

  • @IdeasComo
    @IdeasComo 3 роки тому +1

    gracias crack me sirvio mucho. Saludos desde Colombia

  • @pragyanshreedas23594
    @pragyanshreedas23594 2 роки тому

    please keep posting you are doing greate job and deserve more likes as you explain really well

  • @TarunTejaGurajada
    @TarunTejaGurajada Рік тому

    Thank you for helping me.

  • @haidarjpr8754
    @haidarjpr8754 2 роки тому

    Thanks bro, its help me a lot

  • @arpitagupta5834
    @arpitagupta5834 2 роки тому

    Really Good! Keep making more such videos..

  • @illidan1400
    @illidan1400 Рік тому

    this is special, thanks a ton

  • @surajbaranwal56.
    @surajbaranwal56. 2 роки тому

    Nice explanation 👍

  • @TimesShortVideoChannel
    @TimesShortVideoChannel 2 роки тому

    nice sir, I salute you

  • @fouadsaid5093
    @fouadsaid5093 2 роки тому

    you are a legend bro !

  • @haidarjoo9055
    @haidarjoo9055 Рік тому

    thanks a lot sir 😁

  • @schoellhorn
    @schoellhorn 11 місяців тому

    6:36 what should I use, I couldnt understand it

  • @olddirty4589
    @olddirty4589 Рік тому

    is there a video for the the last thing u did? how to swap to a new activity?

  • @bokzruales4056
    @bokzruales4056 3 роки тому +4

    Where did you put the description of each elements? In another xml file? Sorry I'm still learning mobile dev.

    • @Srimath
      @Srimath 2 роки тому

      Hey if it's on firebase it will be the best

  • @yunoletmehaveaname
    @yunoletmehaveaname Рік тому +1

    Do you have a way to do this between fragments in an activity?

  • @RandyTata-zy2qg
    @RandyTata-zy2qg Рік тому

    I like your video. They are very good and easy to understand. Please can you do a video on a PDF app. That an app that has PDF and when you click on it you can see the contain of the pdf

  • @mobiledevloperroadtopro
    @mobiledevloperroadtopro 2 роки тому

    Perfect Job

  • @twu588
    @twu588 Рік тому

    I put recyclerView on a dynamic layout container , layout.addView(), then "click" is "invoke interface on a null object reference", please help!

  • @dashcode2892
    @dashcode2892 2 роки тому

    Muy bueno, me sirivio!. Crack

  • @0xechidonut
    @0xechidonut Рік тому

    Where did you get the add method for your model class? You didn't even code it in the class itself

  • @brayammatias4832
    @brayammatias4832 Рік тому

    Eres la mera vrga mijo, muchas gracias

  • @ali_x1917
    @ali_x1917 2 роки тому +4

    🔥Great video but I use a Fragment instead of Activity and when i pass the parameter "recyclerView Interface" as "this" show as error What do you think? or what is the alternative of this in Fragment Situation

    • @sleepall4025
      @sleepall4025 2 роки тому

      If your using kotlin then you could add activity instead of this or getActivity().

  • @williamgomez6226
    @williamgomez6226 3 роки тому +3

    Quality videos, thank you so much.
    Are you using an API to retrieve the molecules data? Can you show us how to do that? Thank you again!!

    • @PracticalCoding
      @PracticalCoding  3 роки тому +9

      Actually, I'm not using an API. I got the descriptions from the internet and the names/abbreviations from my biochem book. The vector images of the molecules were made in Adobe Illustrator. I'm gonna be using them in an app I'm working on so probably won't be releasing them😬 Thought it would be cool to use them rather than the default vectors that come with Android Studio. Little different than what everyone else is doing on UA-cam and it's more of a real-world example I think.

  • @TTiTTiMaN
    @TTiTTiMaN Рік тому

    helped me so much

  • @adityarajsinhchauhan7151
    @adityarajsinhchauhan7151 Рік тому

    I getting error in main acitivity adapter where tour error is gone by writing this my is not going and it is sating to create recyclerview interface then making it null

  • @muztabarafid
    @muztabarafid 2 роки тому +1

    Could you please add searching option in this app

  • @yakupakdas6028
    @yakupakdas6028 3 роки тому

    thx it's too helpful

  • @elgimcadiwitan6767
    @elgimcadiwitan6767 Рік тому

    how to solve that get method u put in putextras? it says cant solve method?

  • @DonotDonut-k6c
    @DonotDonut-k6c 8 місяців тому

    Can you create a video on how you create a button in an item? Please and thank you

  • @nickynault812
    @nickynault812 2 роки тому +1

    I am so confused on the very last part where you're putting all the different pages' info on one activity... any way you could go more in depth with me? Struggling for school :(

  • @dgomesreal
    @dgomesreal 2 роки тому +1

    Is it possible to retrieve data from Firebase?

  • @khawajahamdanahmad677
    @khawajahamdanahmad677 2 роки тому

    I cant put this in parameter it is giving me red line in this in adapter parameter in out main activity what should I do

  • @The_Developer7
    @The_Developer7 3 роки тому

    Bro please help
    In Android studio there is an error how to solve it ?
    APPT: error: resources drawable/xyz not found.

  • @ghadarashwan8687
    @ghadarashwan8687 2 роки тому

    Please I need to know how to make the second activity

  • @mobiledevloperroadtopro
    @mobiledevloperroadtopro 2 роки тому

    thanks bro u save me)))))))))))))))

  • @jabseraseyfe2598
    @jabseraseyfe2598 Рік тому

    How we add onclick listner

  • @platinumphonesandcomputers
    @platinumphonesandcomputers 2 роки тому

    Thank you

  • @chuashanjing2261
    @chuashanjing2261 2 роки тому

    How do i add a searchView in this recycler view?

  • @capt.cacksparrow9224
    @capt.cacksparrow9224 2 роки тому

    How to open a pdf when clicked on a recycler view item?

  • @abdulrahman-hr1cx
    @abdulrahman-hr1cx 2 роки тому

    From where can i get these pictures?

  • @aidenfau3209
    @aidenfau3209 2 роки тому

    hi, i get error in int pos = getAdapterPosition();, its on red and nothings work

    • @Purpelxd
      @Purpelxd 2 роки тому

      i got a simillar problem did you solve yours? when i want to write "intent.putExtra("NAME",ProductsModel.get(position).getname);"the .get is in red

  • @leemajelifa5489
    @leemajelifa5489 Рік тому

    Hi sir, how to write code for fragment instead of activity?

    • @huutienang7600
      @huutienang7600 Рік тому

      I doesn't find solution for that, so i only call setOnClick for the layout of item

  • @unatteksen1884
    @unatteksen1884 2 роки тому

    ABİM ÇOK TAŞAKLISIN

  • @jarell2805
    @jarell2805 2 роки тому +1

    how to add the additional information for the next activity, Sir? please we need a tutorial 🥺

    • @Sydewinder890
      @Sydewinder890 2 роки тому

      I just typed the code from the explanation and it works

    • @jarell2805
      @jarell2805 2 роки тому +1

      @@Sydewinder890 it also worked on me, but can't quite follow how to put an extra description, i had my data stored in the string. did u add the additional textview in the adapter? kinda confusing

  • @OP-pv6un
    @OP-pv6un Рік тому

    what if there is SEARCHVIEW??

  • @ratulmondal7154
    @ratulmondal7154 Рік тому

    what about json object?

  • @bestoftheinternet3421
    @bestoftheinternet3421 2 роки тому

    thanks!

  • @amrkeefa4966
    @amrkeefa4966 3 роки тому

    Good work but does this way better than itemCallback ?

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      I'm not sure where I saw this on the Android Developers page but from what I understand, you're supposed to handle what happens in the onClickListener from your activity and use a callback implementation using an interface.
      So in the video, we passed the interface to our adaptor and from the adaptor, we were able to call the callback function when an item was clicked because we set an onClickListener to each of our itemViews.
      Did that answer your question? I'm not entirely sure what you mean by "itemCallback". Maybe we're talking about the same thing?

  • @Ron_Baukanski
    @Ron_Baukanski Рік тому

    Hey dude, is there any way to help?

  • @pragyanshreedas23594
    @pragyanshreedas23594 2 роки тому

    I would like to ask how to do the same while using jet pack lib binding ?????????????????????????????????????????????????????????????????

  • @febieclintlapera3788
    @febieclintlapera3788 3 роки тому

    Anyone here who has an issue in clicking an item in the recyclerview twice to work the setOnlClickListener on the adaptter class?

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      What do you mean by clicking an item twice? I don't think I fully understand the question

  • @АртемБатьков-м6ю
    @АртемБатьков-м6ю 2 роки тому

    But don't forget to add in Manifest new Activity.

  • @emantahir338
    @emantahir338 2 роки тому +1

    bro, may we get this project's source code ❣❣

  • @mulleryeshambel7360
    @mulleryeshambel7360 2 роки тому

    man please send me the source code i need it so urgently

  • @desairajveersinh5837
    @desairajveersinh5837 10 місяців тому

    hi sir where are you frome

  • @medjl6083
    @medjl6083 2 роки тому

    Recyclerview inside fragment, to display item in another fragment is not documented in google and it is not explain in youtube !!!!!!!!!

  • @musiclamat
    @musiclamat 2 роки тому

    good

  • @samirdesigner3324
    @samirdesigner3324 3 роки тому

    thank you
    pls upload this code ):

  • @juliusgaldones5048
    @juliusgaldones5048 2 роки тому

    why you skip coding?

  • @born-in-september
    @born-in-september 2 роки тому

    i hate java interfaces, I prefer to use intent & broadcast methodology...

  • @shoaibalam7126
    @shoaibalam7126 Рік тому

    time waste

  • @chugisan6847
    @chugisan6847 2 роки тому

    You showed all the steps but didn't clarify the last ones. If you don't want others to be able to use what you teach, just don't post videos for views. And what is up with you showing such a zoomed-in portion of your code? It's very difficult to follow.

  • @mihaelpurar6317
    @mihaelpurar6317 Рік тому

    Can someone help me i do everything as in video but i still get this error "error: not an enclosing class: RecyclerViewInterface
    myAdapter = new MyAdapter(ItemView.this, userArrayList, RecyclerViewInterface.this);"
    I am not sure why i get this error, also my program has little bit more code for some other things and i dont know if something in there can cause this problem.

  • @pbdeveloperindian4578
    @pbdeveloperindian4578 Рік тому

    At 5:53, you added this, but not working for me
    My code:-
    ElementsRecyclerAdapter elementsRecyclerAdapter = new ElementsRecyclerAdapter(elementsList,
    ElementsRecyclerActivity.this, this);
    Error:-
    'ElementsRecyclerAdapter(java.util.ArrayList, android.content.Context, com.pbgamesandapps.pbchemx.ElementsRecyclerInterface)' in 'com.pbgamesandapps.pbchemx.ElementsRecyclerAdapter' cannot be applied to '(java.util.ArrayList, com.pbgamesandapps.pbchemx.ElementsRecyclerActivity, anonymous com.android.volley.Response.Listener)'
    My constructor for recycler view adapter :-
    public ElementsRecyclerAdapter(ArrayList elementsList, Context context,
    ElementsRecyclerInterface elementsRecyclerInterface) {
    this.elementsModels = elementsList;
    this.context = context;
    this.elementsRecyclerInterface = elementsRecyclerInterface;
    }
    Interface:-
    package com.pbgamesandapps.pbchemx;
    public interface ElementsRecyclerInterface {
    void onClick(int position);
    }

  • @zexer0_047
    @zexer0_047 2 роки тому

    Nice Video..Uh How do you do the same thing but with opening the information in a fragment instead of switching activty ?

  • @israasalameh6879
    @israasalameh6879 2 роки тому

    What if I'm fill the array by MVVM way ?
    I have tried your way, but the value always returns null in the next activity.
    I have fill the results array by call observe
    mntRequestViewModel.getMntAllReqMutableLiveData().observe(getViewLifecycleOwner(), new Observer() {
    @Override
    public void onChanged(List mntRequests) {
    if (mntRequests == null) {
    Toast.makeText(getActivity(), "failed to get all requests", Toast.LENGTH_LONG).show();
    } else {
    //mntRequests is the array that I should use to get position in onItemClick ...
    allReqResultsAdapter.setResults(mntRequests);

    }
    }
    });

  • @The_Developer7
    @The_Developer7 3 роки тому

    Bro please help
    In Android studio there is an error how to solve it ?
    APPT: error: resources drawable/xyz not found.

  • @은혜-s8z
    @은혜-s8z 2 роки тому

    hello what if i just want the selected item to show a toast message and not a new activity how do i do that

    • @jonispatented
      @jonispatented Рік тому

      Just make a toast message in the click listener, instead of a new intent.

  • @christianvillanueva723
    @christianvillanueva723 2 роки тому

    Thank you

  • @The_Developer7
    @The_Developer7 3 роки тому

    Bro please help
    In Android studio there is an error how to solve it ?
    APPT: error: resources drawable/xyz not found.

  • @The_Developer7
    @The_Developer7 3 роки тому

    Bro please help
    In Android studio there is an error how to solve it ?
    APPT: error: resources drawable/xyz not found.

  • @The_Developer7
    @The_Developer7 3 роки тому

    Bro please help
    In Android studio there is an error how to solve it ?
    APPT: error: resources drawable/xyz not found.