Как написать условие что если в ImageButton background == ic_arrow_drop_down_black_24dp?
<ImageButton
android:id="@+id/spinner"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:background="@drawable/ic_arrow_drop_down_black_24dp"
app:layout_constraintBottom_toBottomOf="@+id/textView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView" />
Вот мой код(Kotlin), срабатывает условие else :)
spinner.setOnClickListener {
if (spinner.drawable == resources.getDrawable(R.drawable.ic_arrow_drop_down_black_24dp)) {
spinner.setBackgroundResource(R.drawable.ic_arrow_drop_up_black_24dp)
Pole.visibility = View.VISIBLE
} else {
spinner.setBackgroundResource(R.drawable.ic_arrow_drop_down_black_24dp)
Pole.visibility = View.GONE
}
}