Control position change of a recyclerview through a progression

Asked

Viewed 325 times

0

I’m trying to make a routine, where I control my item passage from my recyclerView by a progressBar, I mean, every time I change the item, this change has to be reflected in the Ogress. The problem is, I’m only able to catch the position When I click, I can’t pick up by item ticket. Here is the code below: Adapter Code:

private ProgressBar progressBar;
public interface ProgressBar{void Progress(int questao);}
public void ProgressBarListener(ProgressBar progressBar){this.progressBar=progressBar;}

public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    public MyViewHolder(View itemView) {
        super(itemView);
        itemView.setOnClickListener(this);

    }
    @Override
    public void onClick(View v) {
        //Tentativa de pegar a mudança de questão da recycler
        progressBar.Progress(getAdapterPosition());
    }
}

Activity Code:

 //Tentativa de pegar a mudança de questão da recycler
    adapter.ProgressBarListener(new Question2Adapter.ProgressBar() {
        @Override
        public void Progress(int questao) {
            textBar.setText(questao+1+"");
            Log.w("postion",questao+1+"");
            progressBar.setProgress(questao+1);
        }
    });

Screen image:

inserir a descrição da imagem aqui

  • Tried this way: int adapterPosition = MyViewHolder .this.getAdapterPosition() ?

  • I tried agr, inside the Myviewholder constructor returned -1 and in the click returns the position, but only in the click.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.