C
C
Cgfdgfd2021-12-18 20:57:18
android studio
Cgfdgfd, 2021-12-18 20:57:18

How to display an image together with a variable from an array?

I have an array. On button click, it pops up a random animal in the textView . I want each element of the array to have its own image, for example: a wolf is displayed in a textView, and an image of a wolf is displayed in an ImageView. How to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2021-12-18
@Cgfdgfd

android imageview set image resource programmatically
remember the
android formula .... programmatically
in the middle of what and where you want to put
setImageResource() - this is if the pictures are in a drawable or mipmap
In general, study the methods of the standard ImageView . But most likely you will want to take some other component, with zoom and stuff out of the box.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question