1 | int drawableResourceId = this.getResources().getIdentifier("nameOfDrawable", "drawable", this.getPackageName()); | cs |
I warn you, this way of obtaining identifiers is really slow, use only where needed.
https://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-resource-name
https://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-resource-name
https://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-resource-name
'android' 카테고리의 다른 글
[Android] android finished with non-zero exit value 1 에러 대응 (0) | 2019.02.26 |
---|---|
[Android] setUserVisibleHint가 onCreateView보다 먼저 호출될 때 (0) | 2019.02.07 |
[Android] Java code로 동적 spinner 생성하기 (0) | 2019.01.31 |
[Android] DialogFragment에 기본 padding값 제거하는 방법 (0) | 2019.01.29 |
[Android] Type parameter T Has Incompatible upper bounds ViewDataBinding 대처 (0) | 2019.01.29 |