public class FragmentCategory extends Fragment{ //声明viewpager private ViewPager viewPager; //声明数据源 private List<Fragment> list; //声明适配器 private FragmentStatePagerAdapter adapter; //声明view private View view; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view=inflater.inflate(R.layout.fragment_category, container, false); init(); return view; } //初始化控件的方法 private void init() { // TODO Auto-generated method stub //得到viewpager viewPager=(ViewPager) view.findViewById(R.id.viewpager_tab); //得到列表 list=new ArrayList<Fragment>(); //往列表里添加fragment Information information=new Information(); Market market=new Market(); Circle circle=new Circle(); list.add(information); list.add(market); list.add(circle); //声明适配器 adapter=new FragmentStatePagerAdapter(getChildFragmentManager()) { @Override public int getCount() { // TODO Auto-generated method stub return list.size(); } @Override public Fragment getItem(int arg0) { // TODO Auto-generated method stub return list.get(arg0); } @Override public Object instantiateItem(ViewGroup arg0, int arg1) { // TODO Auto-generated method stub return super.instantiateItem(arg0, arg1); } @Override public void destroyItem(ViewGroup container, int position, Object object) { // TODO Auto-generated method stub super.destroyItem(container, position, object); } }; viewPager.setAdapter(adapter); } }
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yanis.yc_ui_fragment_menu/com.yanis.yc_ui_fragment_menu.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
报的错误日志,是在不明白什么意思,请大神指教。。
极光猎人hunter
萨尔诺斯
蜂之谷