Before 2022/Android

ViewPager에서 Fragment의 함수 호출 방법

Eljoe 2019. 1. 24. 16:57
private Fragment findFragmentByPosition(int position) {
	return getSupportFragmentManager().findFragmentByTag(
			"android:switcher:" + viewPager.getId() + ":"
					+ pagerAdapter.getItemId(position));
}

private void callFragmentMethod(int position){
	((YourFragment)findFragmentByPosition(position)).yourMethod();
}