private void invalidateAccountViews(View itemView, int currentIndex, int selectedIndex) { if (itemView == null) { for (int i = 0; i < mAccountsFrame.getChildCount() - 1; i++) { invalidateAccountViews(mAccountsFrame.getChildAt(i), i, selectedIndex); } } else { TextView title = (TextView) itemView.findViewById(R.id.title); ImageView icon = (ImageView) itemView.findViewById(R.id.icon); Account acc = mAccounts.get(currentIndex); switch (acc.type()) { default: icon.setImageResource(R.drawable.ic_folder); break; case Account.TYPE_GOOGLE_DRIVE: icon.setImageResource(R.drawable.ic_drive); break; case Account.TYPE_DROPBOX: icon.setImageResource(R.drawable.ic_dropbox); break; } boolean activated = currentIndex == selectedIndex; itemView.setActivated(activated); icon.getDrawable() .mutate() .setColorFilter(activated ? mSelectedColor : mRegularColor, PorterDuff.Mode.SRC_ATOP); itemView.setTag(currentIndex); title.setText(acc.name()); title.setTextColor(activated ? mSelectedColor : mRegularColor); } }