Pregunta

Estoy tratando de obtener la vista de la pantalla que se muestra actualmente, lo necesito para implementar el siguiente botón anterior para ViewPager, ¿cómo puedo obtener la vista de la pantalla de muestras currenamente? como lo que esta disponible

¿Fue útil?

Solución

you have to use

viewpager.setOnPageChangeListener(new PageListener());

and keep updating the current page when you get a call to the listener. mCurrentPage will give you the required result.

private static class PageListener extends SimpleOnPageChangeListener{

        public void onPageSelected(int position) {
                 mCurrentPage = position;
            }
}

Otros consejos

If you're not doing anything special to ViewPager it should contain child views with same order as in adapter. I'm using following code

View view = mViewPager.getChildAt(mViewPager.getCurrentItem());

Also you can rely on position parameter from method onPageSelected(int position)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top