if you want to get the position of the text you clicked on, you can use this method in onClickListener in the adapter
object.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (object.isChecked() == true) { Log.d("1", "onClick: checked " + getAdapterPosition()); int position = getAdapterPosition(); Class yourObject = yourObject.get(position); yourObject.setChecked(true); selectedyourObjectList.add(todo); } else { if(getAdapterPosition()<selectedyourObjectList.size()) { Log.d("1", "onClick: un checked " + getAdapterPosition()); selectedyourObjectList.remove(getAdapterPosition()); yourObjectList.get(getAdapterPosition()).setChecked(false); } } } });
you can save it in any integer variable and then you can check the text at this position
Hope this helps
source share