Помогите пожалуйста
Вылетает ошибка Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.v7.widget.RecyclerView
В строке
@SuppressLint("WrongViewCast") RecyclerView recyclerView = findViewById(R.id.res);
Класс адаптера
public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder>{
private LayoutInflater inflater;
private List<CoinList> coinList;
DataAdapter(MainActivity context, List<CoinList> coinList) {
this.coinList = coinList;
this.inflater = LayoutInflater.from((Context) context);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.items, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
CoinList coinL = coinList.get(position);
holder.nameView.setText(coinL.getName());
holder.priseView.setText(coinL.getPrise());
}
@Override
public int getItemCount() {
return coinList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
final TextView nameView, priseView;
public ViewHolder(View itemView) {
super(itemView);
nameView = (TextView) itemView.findViewById(R.id.name);
priseView = (TextView) itemView.findViewById(R.id.prise);
}
}
}
класс списка
вpublic class CoinList {
private String name;
private String prise;
//private Image image;
public CoinList(String name,String prise)
{
this.name = name;
this.prise = prise;
}
public String getName() {
return name;
}
public String getPrise() {
return prise;
}
public void setName(String name) {
this.name = name;
}
public void setPrise(String prise) {
this.prise = prise;
}
}
Активити
@SuppressLint("WrongViewCast") RecyclerView recyclerView = findViewById(R.id.res);
adapter = new DataAdapter(this, coinLists);
recyclerView.setAdapter(adapter);