开发者社区> 问答> 正文

关于android中fragment的使用问题。

程序在打开的时候就报错。

这是Android Monitor上的信息:

12-05 01:51:58.359 21231-21231/com.thefat.lingjunqi.enricher E/AndroidRuntime: FATAL EXCEPTION: main
 12-05 01:51:58.359 21231-21231/com.thefat.lingjunqi.enricher E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thefat.lingjunqi.enricher/com.thefat.lingjunqi.enricher.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

展开
收起
爵霸 2016-03-25 09:39:13 1983 0
1 条回答
写回答
取消 提交回答
  • 12-05 01:51:58.359 21231-21231/com.thefat.lingjunqi.enricher E/AndroidRuntime: Caused by: java.lang.IllegalStateException: Fragment ReadingTitleFragment{414f5f38} not attached to Activity
     12-05 01:51:58.359 21231-21231/com.thefat.lingjunqi.enricher E/AndroidRuntime: at android.app.Fragment.getResources(Fragment.java:762)
     12-05 01:51:58.359 21231-21231/com.thefat.lingjunqi.enricher E/AndroidRuntime: at com.thefat.lingjunqi.enricher.ReadingTitleFragment.(ReadingTitleFragment.java:27)

    这个地方是不是就有getActivity了,应该是还没有attached到Activity中有异常

    2019-07-17 19:13:28
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载