android - 使用BottomNavigationBar遇到的一个问题
伊谢尔伦
伊谢尔伦 2017-04-18 09:15:28
0
1
408

我尝试在一个fragment当中使用这个控件然后报错了,我在activity中时候用是可以的

首先是这行View view = inflater.inflate(R.layout.shifting_bottom_navigation_item, this, true);
然后继续跟几次后,
发现它在创建ShiftingBottomNavigationTabvoid init()方法时出错

继续跟进去后,跳转到LayoutInflater.javainflate 方法
然后就到
return inflate(parser, root, attachToRoot);
抛出异常奔溃了

有人用这个控件遇到过问题吗?

出错信息是 android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
我尝试过将图片放到各个文件夹已经drawable 文件下,还是不能解决

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
伊谢尔伦

It is recommended to carefully read the method parameters of LayoutInflater.inflate. The second parameter requires passing in rootLayout, which is the parent layout of the layout you are preparing to inflate. The third parameter is whether to add this view to the parent layout.
So you should write like this here:

inflater.inflate(R.layout.shifting_bottom_navigation_item, container, false); 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template