반응형

Android studio에서 c++ 파일을 사용할 때 로그를 확인 하는 방법에 대해서 알아보겠습니다.

Android.mk 파일

Android.mk

log 사용을 위해서 아래 코드 추가

LOCAL_LDLIBS := -llog

c++ 파일

로그를 확인 하고 싶은 c++ 파일 상단에 log.h 선언


로그

확인하고 싶은 부분에서 아래 코드 입력

 

__android_log_print(ANDROID_LOG_DEBUG, "TAG 이름", "format", 확인하는 부분);


자세한 설명은 아래 공식문서를 참조하시길 바랍니다.

https://developer.android.com/ndk/reference/group/logging

 

Logging  |  Android NDK  |  Android Developers

Stay organized with collections Save and categorize content based on your preferences. Logging #include Summary Enumerations android_LogPriority{  ANDROID_LOG_UNKNOWN = 0,  ANDROID_LOG_DEFAULT,  ANDROID_LOG_VERBOSE,  ANDROID_LOG_DEBUG,  ANDROID_L

developer.android.com

 

반응형
반응형

호출이나 어떠한 동작에 딜레이를 주고싶을 때 사용합니다.

new Handler().postDelayed(new Runnable() {
    @Override
	// 지연할 부분
    }
}, 2000); // 2초

 

반응형
반응형

swipe refresh

데이터를 받아오는 작업을 하거나, 새로고침이 필요한 경우 해당 라이브러리를 사용하여 간단한게 구현할 수 있습니다.


build.gradle

// swipe refresh
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

 

xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/swiperefreshlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".User.UserActivity">
    
    // 내용
    
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

새로고침을 구현할 부분을 SwipeRefreshLayout으로 감싸 줍니다.

Activity

SwipeRefreshLayout swipeRefreshLayout;

...

        // 새로고침
        swipeRefreshLayout = findViewById(R.id.swiperefreshlayout);

        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
            
            // 새로고침 할 부분

                swipeRefreshLayout.setRefreshing(false);
            }
        });

setOnRefreshListener를 호출하여 onRefresh() 부분에 새로고침 할 부분에 대한 코드를 입력하시면 됩니다.

 

가령 어떤 리스트 값을 받아온다고 할때, Retrofit라이브러리의 Get요청을 통해 서버의 데이터를 조회합니다.

Get요청에 대한 코드를 '새로고침 할 부분'에 넣어주시고 화면을 위에서 아래로 쓸어내리면, 해당 동작을 할 때마다 Get요청을 하게 됩니다. 

반응형
반응형

lottie

lottie 애니메이션은 카테고리 옆 이미지, 로딩 다이얼로그 등  화면을 보다 동적으로 보여주기에 목적에 따라 다양하게 활용 될 수 있습니다.

build.gradle

// lottie
    implementation 'com.airbnb.android:lottie:5.0.2'

raw 파일 생성

res 우클릭 - New - Android Resource Directory

Android Resource Deirectory
raw파일 생성


lottie 홈페이지

https://lottiefiles.com/

 

LottieFiles: Download Free lightweight animations for website & apps.

Effortlessly bring the smallest, free, ready-to-use motion graphics for the web, app, social, and designs. Create, edit, test, collaborate, and ship Lottie animations in no time!

lottiefiles.com

원하는 이미지의 JSON파일을 선택해 줍니다.

 

JSON 파일 다운로드

 

다운로드한 파일을 raw에 추가

car.json


xml

<com.airbnb.lottie.LottieAnimationView
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_gravity="center"
    app:lottie_rawRes="@raw/car"
    app:lottie_autoPlay="true"
    app:lottie_loop="true" />

app:lottie_rawRes="@raw/car" 원하는 lottie json파일을 연결 시켜 줍니다.


결과

lottie 애니메이션

반응형

+ Recent posts