Android - Getting a list of drawable resource

前端 未结 4 1898
不知归路
不知归路 2021-01-20 16:16

In android you can access a resource with syntax like R..

what I want to do is to reach a set of images has naming convention.

for example I have 4 files in

4条回答
  •  清酒与你
    2021-01-20 16:46

    well, if you know the suffix of the images, you can request the identifier for a drawable by getResources().getIdentifier(...) and then using the identifier get the drawable. So if you know how many images you have, then you can create a loop and store each of the drawables in a list. Just take into account that such a lookup is relatively expensive.

提交回复
热议问题