Set an OnClickListenerin your ViewHoldercreation: privateclassMyAdapterextendsRecyclerView. However, detecting item clicks is pretty simple. So in our app’s Utils package, we’re going to create the class ItemClickSupport.java. RecyclerView item onClick Raw post.md RecyclerView item onClick RecyclerViewdoes not have an OnItemClickListener like its predecessor, ListView. In our case, we're going to use Hugo Visser's solution, which I've slightly adapted in order to make it a little easier to use. So we're going to have to do it a different way! Additionally, other talented developers have already provided their solutions, as we can see in this Stackoverflow question that has become somewhat famous. This time, the Android developers didn't really make things easy… That's because there's no method like setOnClickListener(int position) that would let us specifically retrieve a click on one list item. Remember, an item on a list visually corresponds to a line in it. First, we'll implement the click on one item in the list. Go back to our application NetApp (also available at this Github commit). The code above is the last part of the puzzle. RecyclerView is mostly used to design the user interface with the fine-grain control over the lists and grids of android application. Well, that’s exactly what we’ll do in this chapter! Manage clicking on an item RecyclerView item onClick Raw post.md RecyclerView item onClick RecyclerViewdoes not have an OnItemClickListener like it's predecessor, ListView. Our application NetApp is pretty nice! However, it would be good if our users could interact by clicking, for example, on one item on the list in order to carry out specific actions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |