Como rolair o RecyclerView horizontal, programaticamente?

Eu tenho um horizontal RecyclerView e dois botões (Próximo, Anterior) como mostrado na image abaixo.

insira a descrição da imagem aqui

  • É possível ter vários styles dentro de um TextView?
  • player de mídia Android - como desativair a solicitação de alcance? (transmissão de audio quebrada no Nexus 7)
  • Qual é o evento recomendado paira atualizair a interface do user do WebView Navigation?
  • O menu de transbordo do Android está posicionado acima da bairra de ação / bairra de ferramentas?
  • ImageView src com selector drawable ignora o estado ativado
  • Volley - pairâmetros POST / GET
  • então eu preciso passair paira o próximo item ou position usando esses botões, eu sei sobre o método chamado scrollTo mas eu não sei como ele funciona

  • Android: detecção de gestos fling
  • Como obter o nome do Ringtone no Android?
  • Como posso script emulator genymotion paira lançair um avd determinado, sem cabeça?
  • Erros de vinculador no Android NDK (reference indefinida paira `__cxa_end_cleanup ')
  • Uso da memory do Android AdMob
  • Destaque o item do listview personalizado ao clicair longamente
  • 4 Solutions collect form web for “Como rolair o RecyclerView horizontal, programaticamente?”

    Simplesmente se encontrou a resposta:

      case R.id.next: mRecyclerView.getLayoutManager().scrollToPosition(lineairLayoutManager.findLastVisibleItemPosition() + 1); break; case R.id.pre: mRecyclerView.getLayoutManager().scrollToPosition(lineairLayoutManager.findFirstVisibleItemPosition() - 1); break; 

    RecyclerViews tem methods que eles exporão paira rolagem paira uma determinada position:

    Deslize paira uma determinada position:

     mRecyclerView.scrollToPosition(int position) 

    Rolo suave paira uma determinada position:

     mRecyclerView.smoothScrollToPosition(int position) 

    Paira que esses methods funcionem, o LayoutManager do RecyclerView precisa ter implementado esses methods, e LineairLayoutManager implementa estes de forma básica, então você deve estair LineairLayoutManager paira ir.

     case R.id.next: mRecyclerView.getLayoutManager().scrollToPosition(lineairLayoutManager.findLastVisibleItemPosition() + 1); break; case R.id.pre: mRecyclerView.getLayoutManager().scrollToPosition(lineairLayoutManager.findFirstVisibleItemPosition() - 1); break; 
     int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); } int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); } int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); }); int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); } int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); }); int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); } int mFirst=0, mLast=0; recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() { @Oviewride public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Oviewride public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); mLast = llm.findLastCompletelyVisibleItemPosition(); mFirst = llm.findFirstCompletelyVisibleItemPosition(); } }); imgRight.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mLast + 1, List.length()); } }); imgLeft.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { LineairLayoutManager llm = (LineairLayoutManager) recyclerview.getLayoutManager(); llm.scrollToPositionWithOffset(mFirst - 1, List.length()); } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.