2021년 2월 6일 토요일

[Android] Jetpack Compose

https://www.youtube.com/watch?v=U5BwfqBpiWU

 Today I would like to tell you about jetpack compose. If you haven't heard about it, Jetpack compose is android's next generation UI Toolkit, written entirely in Kotlin to build high quality applications for Android easily and quickly.

But the best way for you to understand what jetpack compose is and why it's different from existing UI Toolkit is to look at a little bit of code.

so, we'll start with this.

@Composable
fun ProductLabel() {
}

it's a function, it has a single annotation called @Composable and that's pretty much all you need to create  a new widget, what we call composable in the compose world.

you don't have to extend a class,you don't have to overwrite constructors or methods.
you create a function or method and that's it.

it can be private, public, whatever you want, it's just a function. So then to actually generate the UI from that, you gonna take some input.

So in my example, I want to produce a lable for a product.

So I take my product as a parameter of the function, once again, very simple.just a function.
And from then on, I can do what we call "emit the UI".

So i'm going to invoke another composable function,  

@Composable
fun ProductLabel() {
  Text("${Product.quantity}x${product.name}");
}

this one is one of the default composable functions that are part of  jetpack compose, it's called Text.


....


Related Posts:

  • [Android] Thread, Callable, Executor(framework) 쓰레드 다루기최근 coroutine , rx 로 인해 쓰레드 체 관한 처리가 조금 쉬워지긴했다.그래도 옛날 소스들을 보면 java thread, Executor 또는 AsyncTask를 이용해서 만들어진게 많다.이중 주로 외부랑 httpd 통신할때 쓰면 Executor 에 대해 알아보자.그전에 어차피 나올용어로서 Callable 과 Runnable을 알아보자 1 2 3 4 5 6 7 8 9 10 1… Read More
  • [Android] WorkManager 백그라운드 태스크 다루기  Android 에서 백그라운드 서비스, 브로드캐스트등을을 하기위해서 Thread, Async, JobScheduler,알람매니져등이 있지만  최근에는 WorkManager를 이용하기를 권장한다.WorkManager는 주로 백단 에서 작업해야하는 것들에 대해 사용하는데, 앱이 종료되거나 다시시작되더  WorkManager가 작업을 다시 시작해주기 때문에 안정적인 서비스 개시가 가능… Read More
  • [Android] HILT 사용해보자. Spring 에서 서비스단의 클래스를 그냥 어노테이션으로 선언만하고 막쓰던것 처럼 DI해주는 Dagger 라는 라이브러리를 기반으로 안드로이드에서  HILT로 새로 내놓았다고함.Dagger + Android LifeCycle = HILT 라고 생각해도됨. 구글이 Hilt currently supports the following Android classes:App… Read More
  • [Android] Firebase 도입 & 간단 테스트(analytics, fcm)Firebase로 디비저장, 자료저장, 채팅기능, 푸쉬수신기능,분석기능 등 한다. 요즘 다한다.https://firebase.google.com/products-build#develop-products1.firebase 사이트에서 등록하고, 만들고 있고 있는 앱의 package이름을 입력하고, google-serivice.json 을 app폴더(현재프로젝터의  app폴더) 넣어준다.2.Pro… Read More
  • [RxAndroid] RxAndroid 사용해보자. RxJava가 대충(잉?) 알았으니 그걸 Android에서 어케 쓸까 참고해보자.0. gradle에 라이브러리 추가build.gradle (Module:...app) 파일에 rxjava2 추가dependencies {...//Rx Utils dependenciesimplementation 'io.reactivex.rxjava2:rxjava:2.2.19'implementation 'io.re… Read More

0 comments:

댓글 쓰기