Android
[Android] 문자열(String)로 resource ID 얻기
zerocool0713
2021. 8. 13. 11:09
반응형
getIdentifier를 이용하여 리소스 이름, 타입, 패키지명을 파라미터로 넘겨 얻을 수 있음
kotlin
val resourceID = resources.getIdentifier("확장자제외이름", "drawable", packageName)
ex ) drawable 안에 있는 test.png 파일의 리소스 아이디를 가져올 때
val testImageID = resources.getIdentifier("test", "drawable", packageName)
반응형