Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 16, 2019 17:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save parzibyte/7e92c01d3e1a5be01c6bc10a6473f5a6 to your computer and use it in GitHub Desktop.
private void agregarTab(){
// el título del tab
String titulo = String.valueOf(viewPager.getAdapter().getCount() + 1);
adaptadorViewPager.agregarFragmento(new FragmentFormularioDeAvio(), titulo);
adaptadorViewPager.notifyDataSetChanged();
agregarIconoAUltimoTab();
// Enfocar la penúltima 100 milisegundos después
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// Seleccionar la penúltima pestaña
tabLayout.setScrollPosition(viewPager.getAdapter().getCount() - 2, 0, true);
viewPager.setCurrentItem(viewPager.getAdapter().getCount() - 2);
}
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment