@NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater layoutInflater = MainContext.INSTANCE.getLayoutInflater(); view = layoutInflater.inflate(R.layout.channel_rating_details, parent, false); } WiFiChannel wiFiChannel = getItem(position); if (wiFiChannel == null) { return view; } view.<TextView>findViewById(R.id.channelNumber) .setText(String.format(Locale.ENGLISH, "%d", wiFiChannel.getChannel())); view.<TextView>findViewById(R.id.accessPointCount) .setText(String.format(Locale.ENGLISH, "%d", channelRating.getCount(wiFiChannel))); Strength strength = Strength.reverse(channelRating.getStrength(wiFiChannel)); RatingBar ratingBar = view.findViewById(R.id.channelRating); int size = Strength.values().length; ratingBar.setMax(size); ratingBar.setNumStars(size); ratingBar.setRating(strength.ordinal() + 1); int color = ContextCompat.getColor(getContext(), strength.colorResource()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setRatingBarColor(ratingBar.getProgressDrawable(), color); } else { ratingBar.setProgressTintList(ColorStateList.valueOf(color)); } return view; }