how can update date from adapter to recyclerView?

The RecyclerView initialization and notifyDataSetChanged() is used properly. As your question is not clear enough about the Adapter implementation of the RecyclerView, I can give you several suggestions to check.

  1. In RecyclerView.Adapter check if getItemCount() method is properly overriden with returning the list length (not 0) like below:
@Override  
public int getItemCount() {  
    return listdata.length;  
}
  1. In RecyclerView.Adapter check if onCreateViewHolder method is properly overriden with proper xml layout like below:
@Override  
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {  
    LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());  
    View listItem= layoutInflater.inflate(R.layout.coin_xml_layout, parent, false);  
    ViewHolder viewHolder = new ViewHolder(listItem);  
    return viewHolder;  
}
  1. In RecyclerView.Adapter check if RecyclerView.ViewHolder class is properly extended and linked the UI elements from the xml with the adapter like below:
public static class ViewHolder extends RecyclerView.ViewHolder {  
    public TextView coinTextView;  
    public ViewHolder(View itemView) {  
        super(itemView);  
        this.coinTextView = (TextView) itemView.findViewById(R.id.coinTextView);    
    }  
}
  1. In RecyclerView.Adapter check if onBindViewHolder method is properly overridden and updated the list component UI properly like below:
  @Override  
  public void onBindViewHolder(ViewHolder holder, int position) {  
        final MyListData myListData = listdata[position];  
        holder.cointTextView.setText(listdata[position].getCoin());  
    }
  1. Debug with a breakpoint and check if the listCoinDiamondModel.add(coinDiamondModel) is calling or not and coinDiamondModel object is not empty.
  2. The RecyclerView is placed properly in the activity xml, like the RecyclerView is Visible, has a decent size to show list elements. As an example:
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    android:scrollbars="vertical"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top