here is my recycler view adapter snippet.
@Override
protected void
onBindViewHolder(@NonNull ParentStatsViewHolder holder,
int position, @NonNull ChildModal model) {
/*TODO: CURRENTLY SHOW SINGLE ITEM, FIX TO SHOW ALL*/
mapFromFirebase = model.getAppsList();
List<String> keyset = new ArrayList<>(mapFromFirebase.keySet());
List<Long> values = new ArrayList<>(mapFromFirebase.values());
Log.d("ParentStatsAdapter", keyset.toString());
String pkgnamE = keyset.get(position);
holder.pkgName.setText(pkgnamE);
holder.usageTime.setText(DateUtils.formatElapsedTime(values.get(position) / 1000));
Log.d("Positionofsdsd", String.valueOf(position));
}
As you see, when i log "ParentStatsAdapter", it return a whole keyset, which more than 1. The keyset return [Telegram, Blocked Numbers Storage, Package installer, Messenger,]. But when i log "Positionofsdsd", it only return [Telegram]. I already set layout_height="wrap content" for my itemview.
CodePudding user response:
How did you override "getItemCount()"? I will assume that this function at you is not redefined. Add a function that returns the size of your array.
@Override
public int getItemCount() {
return mapFromFirebase.size();
}