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);
If you are using RecyclerView
inside ScrollView
then replace ScrollView
with NestedScrollView
.
Enable android:nestedScrollingEnabled="false"
in RecyclerView.
This solved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With