i use Android Studio Version 3.6 with API 29 and i has problem in the recycler View Adapter in this code
@NonNull
@Override
public MyView onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(getContext()).inflate(R.layout.exampel,parent,false);
return new MyView(view);
}
why i cant use the getContext()??
Because RecyclerView.Adapter
doesn't have a getContext()
method.
You can use parent.getContext()
instead