美文网首页
项目报错:Fragment not attached to a

项目报错:Fragment not attached to a

作者: enchanted1107 | 来源:发表于2022-07-14 14:17 被阅读0次

    在Activity重建的时候,假如fragment还在使用诸如context,就会出现这个问题,比如说突然横屏,fragment里面正在访问网络接口,使用了 new ProgressDialog(context, R.style.waitting_dialog);来进行等待,就会崩溃,Fragment not attached to a context。可以在fragment内部,使用isAdded()来判断是否fragment和activity绑定。

    相关文章

      网友评论

          本文标题:项目报错:Fragment not attached to a

          本文链接:https://www.haomeiwen.com/subject/ifzxirtx.html