I have images in my recyclerview and used adapter I want to fetch the image_id of first image from adapter without click on item I just displayed them in a list and want to fetch image id of first image
this is my recyclerinterface class
public interface RecyclerViewClickInterface {
void onItemClick(int position);
void getItemId(int position);
}
this is my activity want to get image_id of first image in list here how do i specify that image_id should be the id of image at position 0
public void onItemClick(int position) {
Bundle bundle = new Bundle();
int pId = getIntent().getIntExtra("id", 0);
bundle.putInt("id", pId );
SelectFragment select = new SelectFragment();
select.setArguments(bundle);
select.show(getSupportFragmentManager(), select.getTag());
}
@Override
public void getItemId(int position) {
image_id = variations.get(position).getImage_id();
}
this is my adapter class
public void onBindViewHolder(@NonNull VariationViewHolder holder, int position) {
Variations variation = variationList.get(position);
Glide.with(context)
.load(variation.getImage())
.into(holder.binding.imageclr);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
recyclerViewClickInterface.onItemClick(position);
}
});
}