diff --git a/app/src/main/java/com/databits/androidscouting/adapter/MultiviewTypeAdapter.java b/app/src/main/java/com/databits/androidscouting/adapter/MultiviewTypeAdapter.java index bbfd09e..eb77f5b 100644 --- a/app/src/main/java/com/databits/androidscouting/adapter/MultiviewTypeAdapter.java +++ b/app/src/main/java/com/databits/androidscouting/adapter/MultiviewTypeAdapter.java @@ -35,7 +35,6 @@ public class MultiviewTypeAdapter extends RecyclerView.Adapter mCell; - List segmentLabels = new ArrayList<>(); List entryLabels = new ArrayList<>(); public static class YesNoTypeViewHolder extends RecyclerView.ViewHolder { @@ -303,18 +302,16 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int ((SegmentTypeViewHolder) holder).six }; - //Maybe need -1 - for (int i = 0; i < segmentCount; i++) { - segmentLabels.add(object.getSegmentLabels().get(i)); - } - for (int i = 0; i < segmentLabels.size() & segmentCount > i; i++) { - segmentedButtons[i].setText(segmentLabels.get(i)); + int visibleSegmentCount = Math.min(object.getSegmentLabels().size(), segmentCount); + + for (int i = 0; i < visibleSegmentCount; i++) { + segmentedButtons[i].setText(object.getSegmentLabels().get(i)); + segmentedButtons[i].setVisibility(View.VISIBLE); } - for (int i = 0; i < segmentedButtons.length; i++) { - segmentedButtons[i].setVisibility(i < segmentCount ? View.VISIBLE : - View.GONE); + for (int i = visibleSegmentCount; i < segmentedButtons.length; i++) { + segmentedButtons[i].setVisibility(View.GONE); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {