I am developing a navigation box for material design. I created a new class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener in it to process the user by clicking on the list items. I use the class this way in the MainActivity class' onCreate :
mRecyclerView.addOnItemTouchListener( new RecyclerItemClickListener(this, mRecyclerView, new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) {// do whatever if(position!=0){ setItemChecked(position, true); setSelectable(true); boolean isSelected = view.isSelected(); view.setActivated(isSelected); selectItem(position); } } @Override public void onItemLongClick(View view, int position){ // ... } }) );
I based on this code from this blog post: RecyclerView part 2 , but it doesnβt work, and I donβt understand it all about how I should make it work. I also tested this seemingly simple solution: Innodroid - Tracking the selected item in RecyclerView (also cited in this answer ), but it is unclear how I should output the MyAdapter class to the TrackSelectionAdapter class.
What is the best way to highlight list items? I am stuck.
Please, help.
android android-listview material-design android-recyclerview
Cris Cole Apr 17 '15 at 9:46 2015-04-17 09:46
source share