PagerAdapter start position

前端 未结 9 1275

I\'m using the following example to impliment my viewPager: http://code.google.com/p/viewpagerexample/issues/list

The problem with this example is that I can\'t figure o

9条回答
  •  天命终不由人
    2021-01-30 08:37

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View currentPage = null;
        switch(position){
            case 0:
                currentPage = LayoutInflater.from(context).inflate(R.layout.page0, null)    
                break;
            case 1:
                currentPage = LayoutInflater.from(context).inflate(R.layout.page1, null)    
                ///////////// This page will be default ////////////////////
                ((ViewPager)container).setCurrentItem(position);
                ////////////////////////////////////////////////////////////
                break;
            case 2:
                currentPage = LayoutInflater.from(context).inflate(R.layout.page2, null)    
                break;
        return currentPage;
    }
    

提交回复
热议问题