📅  最后修改于: 2022-03-11 14:56:13.790000             🧑  作者: Mango
public class ViewHolder extends RecyclerView.ViewHolder {
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
boolean ischecked = position == checkedposition ? true : false;
holder.tv.setText(productList.get(position));
holder.tv.setChecked(lastSelectedPosition == position);
selectionState.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
lastSelectedPosition = getAdapterPosition();
notifyDataSetChanged();
Toast.makeText(OffersRecyclerViewAdapter.this.context,
"selected offer is " + offerName.getText(),
Toast.LENGTH_LONG).show();
}
});
}