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.
- In
RecyclerView.Adapter
check ifgetItemCount()
method is properly overriden with returning the list length (not 0) like below:
@Override public int getItemCount() { return listdata.length; }
- In
RecyclerView.Adapter
check ifonCreateViewHolder
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; }
- In
RecyclerView.Adapter
check ifRecyclerView.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); } }
- In
RecyclerView.Adapter
check ifonBindViewHolder
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()); }
- Debug with a breakpoint and check if the
listCoinDiamondModel.add(coinDiamondModel)
is calling or not andcoinDiamondModel
object is not empty. - 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.