【发布时间】:2019-05-16 12:46:19
【问题描述】:
我一直在尝试使用 githubrowsersample 对向日葵应用程序示例进行 Restfulise,因此我一直在尝试进行一些复制和粘贴。但是,我对为什么会收到此错误感到完全困惑。此特定代码是完整的复制和粘贴。
我收到的错误是:
错误:DataBoundViewHolder(T) 在 DataBoundViewHolder 中不公开; 不能从 T 是类型变量的外部包访问:T 扩展类 DataBoundViewHolder 中声明的 ViewDataBinding
而我的代码与 this 相同,而是使用这些导入:
import android.annotation.SuppressLint;
import android.os.AsyncTask;
import android.view.ViewGroup;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
我的DataBoundViewHolder代码也是复制粘贴:
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
/**
* A generic ViewHolder that works with a ViewDataBinding
* @param <T> The type of the ViewDataBinding.
*/
public class DataBoundViewHolder<T extends ViewDataBinding> extends RecyclerView.ViewHolder {
public final T binding;
DataBoundViewHolder(T binding) {
super(binding.getRoot());
this.binding = binding;
}
}
感谢您的宝贵时间
【问题讨论】:
-
@IntelliJAmiya 我试过无效缓存的方法,还是没用