Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView is not showing all items in the list

I am using RecyclerView in my app. Every time I open my screen I can see only one item but when I debug it is coming every time to onBindViewHolder method.

Here is my adapter:

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.tourist_details_info, parent, false);

    return new ViewHolder(itemView);
}

@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
    try {
            holder.displayName.setText(list.get(position).toUpperCase());
    }catch (Exception e){
       AxeltaLogger.err("error>>>"+e);
    }
}
@Override
public int getItemCount() {
    return list.size();
}

and this my RecyclerView:

 RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setHasFixedSize(true);
touristAdapter=new TouristInfoAdapter(list);
recyclerView.setAdapter(touristAdapter);
like image 794
Ritu Suman Mohanty Avatar asked Nov 17 '17 10:11

Ritu Suman Mohanty


1 Answers

If you are using RecyclerView inside ScrollView then replace ScrollView with NestedScrollView.

Enable android:nestedScrollingEnabled="false" in RecyclerView.

This solved my problem.

like image 86
suhas sasuke Avatar answered Sep 19 '22 15:09

suhas sasuke