i have this code for the recycler view adapter
public class RvAdapter extends RecyclerView.Adapter<RvAdapter.CardHolder> {
@Override
public CardHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v= LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item,parent,false);
return new CardHolder(v);
}
@Override
public void onBindViewHolder(CardHolder holder, int position) {
}
@Override
public int getItemCount() {
return 10;
}
public class CardHolder extends RecyclerView.ViewHolder {
ImageView bg;
public CardHolder(View itemView) {
super(itemView);
bg=(ImageView)itemView.findViewById(R.id.rvItemImage);
}
}
}
and in the MainActivity
// the recycle view
rv=(RecyclerView)findViewById(R.id.mainBgRv);
adapter=new RvAdapter();
RecyclerView.LayoutManager linearLayoutManager=new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL,false);
try{
rv.setLayoutManager(linearLayoutManager);
rv.setAdapter(adapter);
}catch (Exception e){
Log.i("ERROR_TAG",e.toString());
}
//
when i'm using the the layout manager the app stops and not throwing any exception ... when i remove it its just not showing any item from the rv