I'm trying to read an element from the list shown below (using onClick), with the data being read from a JSON file, the data itself only holds strings. However, I'm having trouble actually registering the array elements to the onClick procedure.
I have absolutely no experience with JSON and am trying to familiarise myself with reading a JSON file and storing it in an Array (which I've done), but I then want to click the individual fields and make it do something.
below is what I have so far:
public void onBindViewHolder(Adapter.ViewHolder holder, int position) {
final ItemFruit itemFruit = fruitList.get(position);
holder.tvFruit.setText(itemFruit.getFruit());
holder.tvPrice.setText(itemFruit.getPrice());
holder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//when item is clicked, TOAST displays the field name
}
});
}
Image of array: array of fruit
Any help whatsoever would be greatly appreciated. Thanks in advance