albinmathew / design-support-library-demo

A simple demo of new Design Support Library for Android
Apache License 2.0
1 stars 1 forks source link

How rise method from purpose fragment #3

Closed Radzhab closed 9 years ago

Radzhab commented 9 years ago

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
    }

      }   
albinmathew commented 9 years ago

Sorry I could't understand your question. Is it related to design support library ?