Android
-
[Android] 문자열(String)로 resource ID 얻기Android 2021. 8. 13. 11:09
getIdentifier를 이용하여 리소스 이름, 타입, 패키지명을 파라미터로 넘겨 얻을 수 있음 kotlin val resourceID = resources.getIdentifier("확장자제외이름", "drawable", packageName) ex ) drawable 안에 있는 test.png 파일의 리소스 아이디를 가져올 때 val testImageID = resources.getIdentifier("test", "drawable", packageName)
-
[Kotlin] 비밀번호 정규식Android 2021. 8. 9. 20:31
숫자, 문자, 특수문자 중 2가지 포함(6~15자) ^(?=.*[a-zA-Z0-9])(?=.*[a-zA-Z!@#$%^&*])(?=.*[0-9!@#$%^&*]).{6,15}$ fun isPasswordFormat(password: String): Boolean { return password.matches("^(?=.*[a-zA-Z0-9])(?=.*[a-zA-Z!@#\$%^&*])(?=.*[0-9!@#\$%^&*]).{6,15}\$".toRegex()) }