반응형 Development/Android55 [android] SwipeRefreshLayout 간단하게 사용하기 라이브러리 추가하기 dependencies { implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" } 새로고침이 필요한 레이아웃 감싸기 새로고침 리스너 달기, 데이터 세팅하기, 새로고침 완료 세팅하기 class MainActivity : AppCompatActivity() { var count: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val textView = findViewById(R.id.text) val refresh = fin.. 2021. 3. 29. [android] ConstraintLayout chainStyle 활용하기 (packed) UI를 만들다보면 아래와 같이 TextView의 넓이에 따라 뷰의 위치가 변경되는 요구사항이 많이 발생된다. TextView에 문자열이 적을 때 TextView의 문자열이 뷰의 최대치를 초과했을 때 이전에는 글자에 넓이를 계산해 뷰의 사이즈를 코드상에서 조절하는 작업을 했던기억이 있다 ConstraintLayout의 chainStyle를 사용하면 쉽게 문제를 해결할 수 있다. 정렬이 필요한 뷰들을 chain으로 묶고 TextView에 아래 옵션을 적용한다. app:layout_constraintHorizontal_chainStyle="packed" // 스타일설정 app:layout_constraintHorizontal_bias="0" // 좌측정렬 app:layout_constraintWidth_def.. 2021. 3. 19. [android] Retrofit2 과 retryWhen 를 조합하여 어떻게 사용할까? 샘플코드를 찾아보면 zipWith 나 take에 flatMap 을 조합하여 사용하는 코드가 많이 보인다. // retrofit2 에 구성한 서비스의 타입은 Single 타입입니다. retryWhen { error -> error.zipWith( Flowable.range(1, 3), BiFunction { _, t2 -> t2 } ).flatMap { i -> Flowable.timer(3, TimeUnit.SECONDS) } } 하지만 reactivex.io 에서 소개하는 방법이 간소하고 명확하게 보인다. Flowable.timer(1, TimeUnit.SECONDS) .doOnSubscribe(s -> System.out.println("subscribing")) .map(v -> { throw ne.. 2021. 3. 19. [android] onTouch 사용 시 ClickableViewAccessibility 주의 onTouch 메소드를 쓸 때 접근성을 위해 perfomClick 을 호출해야 한다고 합니다. 경고를 없에는 방법은 아래와 같습니다. 작업이 끝나고 true가 리턴될때 view.perfomClick을 호출 어노테이션(@SuppressLint("ClickableViewAccessibility"))을 사용 onTouch lambda should call View#performClick when a click is detected If a View that overrides onTouchEvent or uses an OnTouchListener does not also implement performClick and call it when clicks are detected, the View may not h.. 2021. 3. 8. 이전 1 ··· 7 8 9 10 11 12 13 14 다음 반응형