2013-02-07 75 views
0

當我關閉()我的應用程序,並重新打開它onResumeViewPager適配器擴展,則不會調用FragmentPagerAdapter覆蓋方法getItem()。我怎樣才能調用它? 這裏是我的viewPager適配器:的Android viewPager適配器

public class MyPagerAdapter extends FragmentPagerAdapter { 

    private final String TAG = "MyPagerAdapter"; 
    private int MAX_COUNT = 100; 
    fragment1 myFragment; 

    public MyPagerAdapter(FragmentManager fm) { 

     super(fm); 
     Log.d(TAG, "Created adapter for pager"); 

    } 

    public void setCount(int count) { 
     MAX_COUNT = count; 
    } 

    @Override 
    public Fragment getItem(int position) { 

     Log.d(TAG, "getting item at " + position); 

     myFragment = new fragment1(); 

     myFragment.position = position; 
     Log.d("Fragment", "Position: " + position); 

     return myFragment; 
    } 

    @Override 
    public int getCount() { 

     return MAX_COUNT; 

    } 

} 

回答

0

初始化在onStart()視圖尋呼機活動的方法。 OnCreate()方法在創建活動後調用。或者在OnRestart()方法上再次調用它。詳情請見Activity LifeCycle

相關問題