Unable to instantiate fragment make sure class name....

来源:互联网 发布:python 灰帽子 编辑:程序博客网 时间:2024/05/19 02:05

最近使用Viewpager + Fragment来做应用,经常会遇到如下错误

E/UncaughtException-main(13661): java.lang.RuntimeException: Unable to start activity ComponentInfo{......}: android.app.Fragment$InstantiationException: Unable to instantiate fragment xxxxxx...: make sure class name exists, is public, and has an empty constructor that is public

解决办法:

自定义的fragment 如果只定义了带参数的构造方法,那么要把参数为空的构造函数一并写上。原因待进一步研究,知道的朋友不吝赐教!




0 0
原创粉丝点击