Notice
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 리스트뷰
- layout
- Unity
- bottom
- DP
- GPS
- WebCamTexture
- 그래들
- Ext
- 스피너
- 조이스틱
- camera
- Android
- 레이아웃
- gradle
- ListvView
- webcam
- GlobalComponent
- 안드로이드
- Round Square
- Handelr
- 유니티
- spinner
- UI
Archives
- Today
- Total
JY-Dev Tech Blog
안드로이드(Android) - Drawable Arraylist (이미지 배열) 본문
[OverView]
이번에는 Drawable ArrayList 생성하는 방법에 대해 알려드리겠습니다.
일단 app/res/values 에 arrays Resource를 생성해 줍시다.
[values.xml]
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
그러면 이런 형태로 생성이 될텐데 이안에 array를 생성해 줍시다.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="sample_image">
<item>@drawable/sample01</item>
<item>@drawable/sample02</item>
</array>
</resources>
이런식으로 array에 drawable를 넣어주도록 합시다.
이미지를 불러오려면 TypedArray로 선언을 해줘야합니다.
val imageDrawableArray = Context.resources.obtainTypedArray(R.array.weather_image)
그리고나서 값을 가져오는 방법
var drawable = mageDrawableArray.getDrawable(Index)
'안드로이드 > 그 외 여러가지' 카테고리의 다른 글
안드로이드(Android) - Handler Deprecated? (1) | 2020.08.13 |
---|---|
안드로이드(Android) - View Set Id dynamically(View Id 동적 Set) (0) | 2020.08.11 |
안드로이드(Android) - Int to Dp , Float to Dp (Dp 변환) (0) | 2020.08.11 |
안드로이드(Android) - Gps On Off 확인 (위치 서비스 활성화) (1) | 2020.07.16 |
리소스에서 Drawable Localization (1) | 2018.11.05 |
Comments