M
M
Muslim Mamaev2022-04-08 17:53:11
Java
Muslim Mamaev, 2022-04-08 17:53:11

How to set an icon?

if (listPosition == 6) {
            if (isPurchasedKey) {
                ivLock.setImageResource(R.drawable.ic_baseline_lock_open_24);
            } else {
                if (listPosition == 6) {
                    ivLock.setImageResource(R.drawable.ic_baseline_lock_24);
                }
            }
        }

This code sets the icon to the 6th section. How can I add an icon to the 5th section as well? I've done something on my own, tell me right? If not right
if (listPosition == 6 && listPosition == 5) {
            if (isPurchasedKey) {
                ivLock.setImageResource(R.drawable.ic_baseline_lock_open_24);
            } else {
                if (listPosition == 6 && listPosition == 5) {
                    ivLock.setImageResource(R.drawable.ic_baseline_lock_24);
                }
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2022-04-08
@muslim_mamaev

instead of && you need ||

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question