본문 바로가기

전체 글

(140)
초급 10, 11 클래스와 상속 클래스 정의 class Car: def __init__(self, seat, handle_size, wheel, luggage): self.seat = seat # __속성명: private self.__handle_size = handle_size self.wheel = wheel # _속성명: protected self._luggage = luggage print("Car.__init__") def honk(self): print("빵빵") def drive(self): print("자동차가 출발합니다") def load_luggage(self, luggage): if luggage > self._luggage: print("적재물이 너무 많습니다") else: print("자동차에 " + lugga..
7. Databases and RecyclerView - RecyclerView Fundamentals RecyclerView RecyclerView 구현하기 Implement RecyclerView and an Adapter Step 1: LayoutManager와 RecyclerView 추가하기 github.com/google-developer-training/android-kotlin-fundamentals-starter-apps/tree/master/RecyclerViewFundamentals-Starter google-developer-training/android-kotlin-fundamentals-starter-apps android-kotlin-fundamentals-starter-apps. Contribute to google-developer-training/android-kotlin-f..
7. Databases and RecyclerView - Use LiveData to control Button states Add navigation Record the sleep quality coroutine 패턴 사용 viewModelScope에서 coroutine launch sleepNightKey를 사용해 tonight 얻기 sleep quality 설정 database 업데이트 navigation 실행(trigger) Control button visibility and add a snackbar transformation maps Step 1: 버튼 상태 업데이트하기 fragment_sleep_tracker.xml
7. Databases and RecyclerView - Use coroutines with Room Inspect the starter code 코드 살펴보기 이 코드랩의 스타터 코드는 이것과 같다. activity_main.xml은 nav_host_fragment를 가지고 있다. merge 태그는 레이아웃을 포함할 때 불필요한 레이아웃을 제거할 수 있다. 불필요한 레이아웃이란 예를 들어 ConstraintLayout>LinearLayout>TextView가 있을 때 시스템이 LinearLayout을 제거할 수 있는 경우를 말한다. 이런 류의 최적화는 view hierarchy를 단순화하고 앱 성능을 향상시킬 수 있다. Add a ViewModel Step 1: SleepTrackerViewModel 추가하기 SleepTrackerViewModel.kt class SleepTrackerViewModel..
7. Databases and RecyclerView - Create a Room database github.com/google-developer-training/android-kotlin-fundamentals-starter-apps/tree/master/TrackMySleepQuality-Starter google-developer-training/android-kotlin-fundamentals-starter-apps android-kotlin-fundamentals-starter-apps. Contribute to google-developer-training/android-kotlin-fundamentals-starter-apps development by creating an account on GitHub. github.com Create the SleepNight entity Andr..
초급 9 XML 지난 번에 활용신청 해둔 오픈 API를 활용해볼 것이다. 활용신청을 하면 일반 인증키(UTF-8)이 주어지는데 get하는 과정에서 utf-8로 인코딩이 되기 때문에 utf-8로 인코딩된 데이터가 아닌 디코딩된 데이터를 get에 넘겨주어야 한다. Google에 url decoder라고 검색한 후 아무 사이트에서 서비스키(utf-8)를 디코딩하고 복사&붙여넣기 하면 된다. In: import requests payload = {'serviceKey': '디코딩한 서비스키', 'numOfRow': '10', 'pageNum': '1', 'sidoName': '서울', 'ver': '1.3', '_returnType': 'json' } response = requests.get('http://openapi.ai..
초급 8 REST, JSON REST REQUEST RESPONSE REQUEST URL(Uniform Resource Locator)은 URI(Uniform Resource Identifier)에 포함되는 개념이다. REQUEST METHOD METHOD 설명 POST 리소스 생성 PUT 리소스 수정 GET 리소스 조회 DELETE 리소스 삭제 RESPONSE CODE 설명 200 요청 정상 수행 201 요청한 리소스 생성 완료 400 요청이 부적절함 404 요청한 리소스 없음 500 서버에 오류가 있음 Open API 리퀘스트 URI가 하나의 Open API이다. www.data.go.kr/ 공공데이터 포털 국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국..
초급 7 딕셔너리, 프로그램 설계 {딕셔너리} >>> dict = {"사과":5000, "바나나":3000} >>> dict {'사과': 5000, '바나나': 3000} >>> dict["사과"] 5000 >>> dict["바나나"] 3000 >>> dict["없음"] Traceback (most recent call last): File "", line 1, in KeyError: '없음' >>> dict["사과"] = 7000 >>> dict {'사과': 7000, '바나나': 3000} >>> dict["오렌지"] = 9000 >>> dict {'사과': 7000, '바나나': 3000, '오렌지': 9000} >>> del dict["사과"] >>> dict {'바나나': 3000, '오렌지': 9000} >>> del dict..