How save the state of RecyclerView row item?
<p>I have a recyclerview which populates data from SQL database. Now each row in the recyclerview has a seekbar which when moved displays it's progress in a textview inside the same row. The problem is when I scroll the recyclerview up or down then return back to the first changed row, the seekbar is returned to its default position. How can I make it save the new position ? In normal activities/fragments I use lifecycle methods as "onPause" to save/restore the state. Here we have onAttachedToRecyclerView, I think it should solve my problem but I don't know exactly how.</p>

<p><strong>EDIT</strong> : here is a full simple app files which I'm working on to test this problem.</p>

<p>MainActivity.class</p>

<pre><code>public class MainActivity extends AppCompatActivity {
    private List&lt;Score&gt; scoreList = new ArrayList&lt;&gt;();
    private RecyclerView recyclerView;
    private MyAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);

    mAdapter = new MyAdapter(scoreList);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

    prepareScoreData();
}

private void prepareScoreData() {
    Score score = new Score("title", 5);
    scoreList.add(score);

    for(int i= 0; i&lt;1000; i++){
        score = new Score("title", 5);
        scoreList.add(score);
    }

    mAdapter.notifyDataSetChanged();
}
}
</code></pre>

<p>MyAdapter</p>

<pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.MyViewHolder&gt; {
private List&lt;Score&gt; scoresList;

public class MyViewHolder extends RecyclerView.ViewHolder {
    TextView title, scoreView;
    SeekBar seekbar;

    public MyViewHolder(View view) {
        super(view);
        title = (TextView) view.findViewById(R.id.title);
        scoreView = (TextView) view.findViewById(R.id.score);
        seekbar = (SeekBar) view.findViewById(R.id.seekbar);
    }
}


public MyAdapter(List&lt;Score&gt; scoresList) {
    this.scoresList = scoresList;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.item, parent, false);

    return new MyViewHolder(itemView);
}


@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
    final Score score = scoresList.get(position);
    holder.title.setText(score.getTitle());

    if (!score.getProgressed()) {
        holder.seekbar.setProgress(0) ;
    } else {
        holder.seekbar.setProgress(score.getSeekbarProgress());
    }

    holder.seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            holder.scoreView.setText(String.valueOf(i));
            score.setSeekbarProgress(i);
            score.setProgressed(true);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
}

@Override
public int getItemCount() {
    return scoresList.size();
}
}
</code></pre>

<p>Score class</p>

<pre><code>public class Score {
private String title;
int seekbarProgress;
boolean progressed;

public Score() {
}

public Score(String title,int seekbarProgress) {
    this.title = title;
    this.seekbarProgress = seekbarProgress;
}

public void setProgressed(boolean progressed) {
    this.progressed = progressed;
}



public void setTitle(String title) {
    this.title = title;
}

public void setSeekbarProgress(int seekbarProgress) {
    this.seekbarProgress = seekbarProgress;
}

public String getTitle() {
    return title;
}

public int getSeekbarProgress() {
    return seekbarProgress;
}

public boolean getProgressed() {
    return progressed;
}
}
</code></pre>

<p>MainActivity_Layout</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.moaness.tut_recyclerview.MainActivity"&gt;

    &lt;!-- A RecyclerView with some commonly used attributes --&gt;
    &lt;android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/&gt;
    &lt;/RelativeLayout&gt;
</code></pre>

<p>item.xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="60dp"
    android:paddingBottom="60dp"
    android:layout_marginBottom="10dp"
    android:clickable="true"
    android:background="#f2f2f2"
    android:orientation="vertical"&gt;

    &lt;TextView
        android:id="@+id/title"
        android:text="title"
        android:textColor="@color/title"
        android:textSize="16dp"
        android:paddingTop="16dp"
        android:textStyle="bold"
        android:layout_alignParentTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" /&gt;

    &lt;TextView
        android:id="@+id/score"
        android:text="score"
        android:layout_below="@+id/title"
        android:textSize="16dp"
        android:paddingBottom="16dp"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" /&gt;

    &lt;SeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/score"
        android:id="@+id/seekbar"
        /&gt;

&lt;/RelativeLayout&gt;
</code></pre>