N
N
ngapp2019-12-08 17:44:18
Java
ngapp, 2019-12-08 17:44:18

How to output random avatar from drawables in ActivityFragment?

Hello everyone, another problem,
there are drawables, which has avatar_1.xml, avatar_2.xml, avatar_3.xml.
How to implement, so that when filling out the form in the fragment, an image is added randomly from this list?
A form with a choice of images, but it is necessary that by itself and by chance.
5ded0bfb54ef7922810496.png
Output in the snippet
5ded0c3cf1287859421722.png
Thank you!!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-12-08
@hypnogaja

Make an array of IDs and choose a random index from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question