how to add radio button in recyclerview android code example

Example: recyclerview with radio button android

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();
                }
            });
    }

Tags:

Misc Example