android 下自定义view, android.view.InflateException

最近在写一个DEMO APP的时候,使用自己定义的一个view,在MainActivity布局文件中:

android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"

/>

运行的时候报错,android.view.InflateException: Binary XML file line #5: Error inflating class ,在网上看到很多人的解决方法,大多是1.拼写错误。2.构造函数漏写。3.资源占用内存太大(图片)。。。。等等,一一试过还是报这个错误。

最后实在没方向,把自定义view文件的init function 移到MainActivity,再次运行时报错arrayoutofboundexception,数组越界。仔细检查发现确实有个数组越界访问。问题解决。


不当之处还请指正,仅给各位提供参考。。



你可能感兴趣的:(android)