gpt4 book ai didi

android - fragment 应该是静态的,这样它们可以被系统重新实例化,而匿名类不是静态的 [ValidFragment]

转载 作者:行者123 更新时间:2023-12-02 01:22:58 24 4
gpt4 key购买 nike

错误:错误: fragment 应该是静态的,这样它们才能被系统重新实例化,而匿名类不是静态的[ValidFragment]

private boolean checkFreeSpace(String path, long size) {
long freeSpace = StorageUtil.getAvailableSpaceInBytes(path);
if (freeSpace <= size) {

问题来了>>> new DialogFragment() {

最佳答案

如文档所述(Fragment Documentation):

Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle) and later retrieved by the Fragment with getArguments().

所以我猜你正在扩展/实现一个 fragment 类并用参数重载一个构造函数。

您可以使用上面解释的 setArguments(Bundle) 方法修复它。

关于android - fragment 应该是静态的,这样它们可以被系统重新实例化,而匿名类不是静态的 [ValidFragment],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38821922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com