I have a ViewPager, and I'd like to get the current selected and visible view, not a position.
getChildAt(getCurrentItem)
returns wrongView
This works not all the time. Sometimes returns null, sometimes just returns wrong View.
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser == true) { mFocusedListView = ListView; } }
PageListener on
ViewPager
withgetChildAt()
also not working, not giving me the correct View every time.
How can i get current visible View?
View view = MyActivity.mViewPager.getChildAt(MyActivity.mViewPager.getCurrentItem()).getRootView();
ListView listview = (ListView) view.findViewById(R.id.ListViewItems);