所以基本上我想在ViewPager中填充页面,为每个视图位置使用单独的
XML布局.我现在正在这样做
@Override public Object instantiateItem(View container,int position) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE); if(position == 0){ view = inflater.inflate(R.layout.main,null); ((ViewPager) container).addView(view,0); } if(position == 1){ view = inflater.inflate(R.layout.main_second,null); ((ViewPager) container).addView(view,0); } if(position == 2){ view = inflater.inflate(R.layout.main_third,0); } return view; }
首先正确显示视图,但是当我滑动ViewPager时,将隐藏/销毁布局.为什么是这样?我这样做是错误的吗?请帮助并纠正我.
谢谢.
爱.韦斯利