How Can I Get The Current Item Position In Recyclerview After Filtering Item Using Custom Searchview
when I type & search item name in Custom Search view basically its an Editext which in I am typing searching text, but after searching the item for example banana it properly f
Solution 1:
I'm still not sure of what you trully want but you can try this :
Inside the bindViewHolder in your class adapter, write this :
holder.itemView.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
AdapterItemcurrentItem= mAdapterList.get(position);
if (currentItem.getText1().contains(fruitnames[position])) {
Toast.makeText(getApplicationContext(), "name displayed:" + currentItem.getText1() , Toast.LENGTH_SHORT).show();
}
}
});
And you remove the recyclerView.addOnItemTouchListener...
Solution 2:
Added for Loop in Onclick & solved my Problem
for(int i= 0 ;i< fruitnames.length;i++){
if (currentItem.getText1().contains(fruitnames[i])) {
Toast.makeText(getApplicationContext(), "name displayed:" + currentItem.getText1() , Toast.LENGTH_SHORT).show();
}
}
Post a Comment for "How Can I Get The Current Item Position In Recyclerview After Filtering Item Using Custom Searchview"