gpt4 book ai didi

java - 无法从外部包访问

转载 作者:行者123 更新时间:2023-12-02 05:35:39 30 4
gpt4 key购买 nike

我一直在尝试使用 githubrowsersample 来 Restfulise 向日葵应用程序示例,因此我一直在尝试进行一些复制和粘贴。但是,我完全困惑为什么我会收到此错误。此特定代码是完整的复制和粘贴。

我收到的错误是:

error: DataBoundViewHolder(T) is not public in DataBoundViewHolder; cannot be accessed from outside package where T is a type-variable: T extends ViewDataBinding declared in class DataBoundViewHolder

我的代码与 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;
}
}

感谢您的宝贵时间

最佳答案

使您的类(class)公开

    public class DataBoundViewHolder<T extends ViewDataBinding> extends RecyclerView.ViewHolder {
..
}

因为我想现在它是package-private

关于java - 无法从外部包访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56168936/

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