Android Unable to instantiate fragment

来源:互联网 发布:mac 隐藏桌面 编辑:程序博客网 时间:2024/05/05 18:47

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.activity/com.example.activity.PreferenceActivityTest}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.PreferenceActivityTest$Prefs1Fragment: make sure class name exists, is public, and has an empty constructor that is public

上面的是我的一段错误输出,

经查阅资料得知出现Unable to  instantiate fragment 有一下几种解决方法

(1) 首先检查在XML文件中应用的Fragment类的包名和类名是否有错

(2) 在Fragment类中要写一个共有的空的构造函数,不写的话,会出错

  

以后如果还有什么的话,还会继续补充

0 0
原创粉丝点击