Q:

display clicked value in recycler view in android

HI I'm new to android and I'm fetching data from db and displaying in recycler view.  How to get the value of the item clicked.  I'm able to get the position but I'm not sure how to get the value. 
import android.content. Context;
import android.support.v7.widget. RecyclerView;
import android.util. Log;
import android.view. LayoutInflater;
import android.view. View;
import android.view. ViewGroup;
import android.widget. TextView;
import android.widget. Toast;
import java.util. Collections;
import java.util. List;

public class AdapterSearch extends RecyclerView. Adapter<RecyclerView. ViewHolder> {

    private Context context;
    private LayoutInflater inflater;
    List<DataSearch> data= Collections.emptyList();
    DataSearch current;

    // create constructor to initialize context and data sent from MainActivity
    public AdapterSearch(Context context, List<DataSearch> data){
        this.context=context;
        inflater= LayoutInflater.from(context);
        this.data=data;
    }

    // Inflate the layout when ViewHolder created
    @Override
    public RecyclerView. ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=inflater.inflate(R.layout.container_search, parent,false);
        MyHolder holder=new MyHolder(view);
        return holder;
    }

    // Bind data
    @Override
    public void onBindViewHolder(RecyclerView. ViewHolder holder, int position) {

        // Get current position of item in RecyclerView to bind data and assign values from list
        MyHolder myHolder= (MyHolder) holder;
        DataSearch current=data.get(position);
        myHolder.textsanctname.setText(current.sanctname);
        myHolder.textstate.setText("State " + current.state);
        myHolder.textType.setText("Category " + current.catagory);

    }

    // return total item from List
    @Override
    public int getItemCount() {
        return data.size();
    }

    class MyHolder extends RecyclerView. ViewHolder implements View. OnClickListener{

        TextView textsanctname;
        TextView textstate;
        TextView textType;

        // create constructor to get widget reference
        public MyHolder(View itemView) {
            super(itemView);
            textsanctname= (TextView) itemView.findViewById(R.id.textsanctname);
            textstate = (TextView) itemView.findViewById(R.id.textstate);
            textType = (TextView) itemView.findViewById(R.id.textType);

            itemView.setOnClickListener(this);
        }

        // Click event for all items
        @Override
        public void onClick(View v) {

            Toast.makeText(context, "You clicked "+getPosition(),Toast. LENGTH_SHORT).show();

        }

    }

}

Thanks in advance. 

A:

    // Click event for all items
    @Override
    public void onClick(View v) {
        DataSearch clickedData = data.get(getPosition()); 
        Toast.makeText(context, "You clicked "+clickedData.getXXX(),Toast. LENGTH_SHORT).show();

    }

Assign the value into a variable and you may display the value in Toast.