我正在尝试实现这个库。此处编写的示例代码是在 Kotlin 中编写的,但我的项目是在 Java 中编写的,因此我尝试将代码从 kotlin 转换为 java。但我收到以下错误:
android.view.InflateException:二进制 XML 文件第 2 行:二进制 XML 文件第 2 行:错误膨胀类 androidx.cardview.widget.CardView 引起:android.view.InflateException:二进制 XML 文件第 2 行:错误膨胀类 androidx .cardview.widget.CardView 引起:java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method)
在膨胀cardview
class CardStackAdapter extends RecyclerView.Adapter<CardStackAdapter.ViewHolder> {
private Context context;
private ArrayList<Spot> listItem;
public CardStackAdapter(Context applicationContext, ArrayList<Spot> listItem) {
this.context = applicationContext;
this.listItem = listItem;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.test, parent, false); // ----> I am getting error here..
return …
Run Code Online (Sandbox Code Playgroud)