본문 바로가기

Android58

Android Coroutine example 코루틴 권장사항 1. 새 코루틴을 만들거나 withContext를 호출할때 Dispatchers를 하드코딩하지 마세요. -> 코드의 유연성, 테스트 용이성을 위함. 직접 하드코딩하게 되면 테스트나 리팩토링이 어려워진다. 하드코딩된 Dispatchersimport kotlinx.coroutines.*fun fetchData() { GlobalScope.launch(Dispatchers.IO) { // 일부 오래 동작하는 작업 val data = performNetworkRequest() withContext(Dispatchers.Main) { // UI 업데이트 updateUI(data) } }} 하드코딩을 .. 2024. 7. 4.
Compose Box Basic Style 여러가지 Box Style@Preview(showBackground = true)@Composableprivate fun BoxSample() { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(4.dp)) { Box( modifier = Modifier .clip(CircleShape) .background(Color.Red) .size(44.dp) ) Box( modifier = Modifier .size(44... 2024. 6. 3.
RoomDatabase Hilt Error -> AppDatabase. AppDatabase_Impl does not exist at androidx.room.Room.getGeneratedImplementation(Room.kt:58) .. AppDatabase. AppDatabase_Impl does not exist at androidx.room.Room.getGeneratedImplementation(Room.kt:58) at androidx.room.RoomDatabase$Builder.build(RoomDatabase.kt:1351) RoomDatabase를 Hilt를 사용하면서 AppDatabase_Impl를 찾을 수 없었다. 구글 검색 결과 @어노테이션 문제인거 같았고 Retrofit2는 Hilt가 정상적으로 동작하는것으로봐서 build.gradle에 차이점 찾아보기로 했다. Retrofit2는 ksp로 변경했으나 Room 라이브러리는 ksp를 사용하지 않았다. . ksp로 변경 뒤 빌드해보니 아래 코드를 추가로 작성해줘야 했다.. 2024. 4. 14.
RecyclerView 하단 divider 깜빡임 | RecyclerView bottom divider blinking Finally got it! Yet another stupid mistake, it's not complicated at all, I kept thinking, why I'm having this problem only on this activity, but not my previous one, and I suddenly realized that the layout in the two activities are different, turns out I set the RecyclerView's height to wrap_content, so I suppose what happened is that, the layout told the system to wrap the content in the Recycl.. 2024. 3. 26.
Android constraint layout id 중복으로 사용하기 view를 visible, gone하면서 ui를 일정하게 유지하고 싶었다. How to set constraint to two views? https://stackoverflow.com/questions/50047796/how-to-set-constraint-to-two-views How to set constraint to two views? So I have a constraintLayout like this 2024. 2. 27.
Android Room DB 간단한 메모DB 만들어보기 + 주의할점 1. 의존성 추가 (최신 버전으로 업데이트) dependencies { def room_version = "2.4.1" implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" // optional - Kotlin Extensions and Coroutines support for Room implementation "androidx.room:room-ktx:$room_version" } 2.entity추가 import androidx.room.Entity import androidx.room.PrimaryKey @Entity data class Memo( @Primary.. 2024. 1. 5.