Based on the following links you can build up your solution
https://gist.github.com/grantland/cd70814fe4ac369e3e92
Get clicked item and its position in RecyclerView
http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
So basically you need to check if the certain item of the recyclerview is onclicked. If yes just flip the visibility of the progressbar and the image.
You have a recyclerview similar to this one, let's assume on the activity_main layout:
<android.support.v7.widget.RecyclerView
android:id="@+id/myRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</android.support.v7.widget.RecyclerView>
in MainActivity's onCreate add:
MainAdapter mainAdapter = new MainAdapter(new String[] {"apple", "banana", "coconut"});
RecyclerView myRecyclerView = (RecyclerView) findViewById(R.id.myRecyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
myRecyclerView.setLayoutManager(layoutManager);
myRecyclerView.setAdapter(mainAdapter);
create a row_recycler_list under the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/myProgressBar"
android:layout_width="100dp"
android:layout_height="100dp"
android:visibility="gone"
/>
<ImageView
android:id="@+id/myImage"
android:src="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/myText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
your viewholder implements the View.OnClickListener like this one:
package com.example.jana.recyclerimage;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
private String[] dataSet;
public MainAdapter(String[] dataSet) {
this.dataSet = dataSet;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater
.from(parent.getContext())
.inflate(R.layout.row_recycler_list, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.textView.setText(dataSet[position]);
}
@Override
public int getItemCount() {
return dataSet.length;
}
public class ViewHolder
extends RecyclerView.ViewHolder
implements View.OnClickListener {
public TextView textView;
public ViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
this.textView = (TextView)itemView.findViewById(R.id.myText);
}
@Override
public void onClick(View v) {
ImageView imageView = (ImageView) v.findViewById(R.id.myImage);
ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.myProgressBar);
imageView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
}
}
}
and basically you're done. Of course you can extend and/or polish it according to your needs.