android - How to make RecycleView Clickable In a Fragment? -
i parsing json data in fragment. view of json data used recycleview. in fragment showed short detail of post. want when user click recycleview go activity , show details of post. how make recycleview clickable?
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.fragment_recent_post, container, false); recentpostrecycleview = (recyclerview) view.findviewbyid(r.id.recent_posts); recentpostrecycleview.setlayoutmanager(new linearlayoutmanager(getactivity())); recentpostadapter = new recentpostadapter(getactivity()); recentpostrecycleview.setadapter(recentpostadapter); sendjsonrequest(); return view; }
my recycleview screenshoot:
you should not make recyclerview clickable, cards. add android:clickable="true"
card layout , add clicklistener childviews. if struggle that, slidenerd has nice tutorial recyclerviews: https://www.youtube.com/watch?v=ze1e1hok_e4
Comments
Post a Comment