I want from MainActivity get CheeseListFragment method GetRequest. I create 10 instance of CheeseListFragment.
MainActivity.java
private void setupViewPager(ViewPager viewPager, String[] items) {
adapter = new Adapter(getSupportFragmentManager());
for (int i=0; i<items.length; i++){
adapter.addFragment(new CheeseListFragment(), items[i]);
}
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (adapter!=null) {
List<Fragment> list = new ArrayList<Fragment>();
list = adapter.mFragments; // Get Curren
list[i].GetRequest; // I want make it
}
}
}
CheeseListFragment.java
public class CheeseListFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
.....
return rv;
}
public void GetRequest(int page){
/// http get request
}
}
I want from MainActivity get CheeseListFragment method GetRequest. I create 10 instance of CheeseListFragment.
MainActivity.java
CheeseListFragment.java