2013-06-19

Adnroid get current fragment when using ViewPager

1. Get current select view page

ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
int id = viewPager.getCurrentItem();
2. Get Fragment by tag
Fragment frag = getFragmentManager().findFragmentByTag("android:switcher:"+R.id.pager+":"+id); 
Then you can access your fragment reference.

No comments: