今天有个需求,要用ViewPager加载自定义布局
具体是在ViewPager的apdater(继承自PagerAdapter)里面操作:
在instantiateItem方法里:

View view = LayoutInflater.from(mContext).inflate(R.layout.item_layout_course_outline,container,false);//这里传的false,如果不传这个参数,会报错“viewpager java.lang.IllegalStateException: The specified child already has a parent”
ViewPager自定义布局
本文介绍如何在ViewPager的PagerAdapter中加载自定义布局,特别是在instantiateItem方法内使用LayoutInflater从上下文中inflate指定布局文件的过程。
3088

被折叠的 条评论
为什么被折叠?



