I have a ViewPager, and I\'d like to get the current selected and visible view, not a position.
getChildAt(getCurrentItem)
returns wrong Vi
If you do not have many pages and you can safely apply setOffscreenPageLimit(N-1)
where N is the total number of pages without wasting too much memory then you could do the following:
public Object instantiateItem(final ViewGroup container, final int position) {
CustomHomeView RL = new CustomHomeView(context);
if (position==0){
container.setId(R.id.home_container);} ...rest of code
then here is code to access your page
((ViewGroup)pager.findViewById(R.id.home_container)).getChildAt(pager.getCurrentItem()).setBackgroundColor(Color.BLUE);
If you want you can set up a method for accessing a page
RelativeLayout getPageAt(int index){
RelativeLayout rl = ((RelativeLayout)((ViewGroup)pager.findViewById(R.id.home_container)).getChildAt(index));
return rl;
}