본문 바로가기
728x90

전체 글155

[android][kotlin] 카메라 권한 얻어 사용하기 카메라를 이용해봅시다! 각각 카메라 권한을 얻기 위한 구문(android developer)이랑 카메라 앱을 이용하기 위한 구문(android developer)을 Manifest에 추가해줍시다. 그리고 UI에 카메라 앱을 실행해줄 버튼을 하나 만들어줍시다. 버튼을 누르면 카메라를 이용할 수 있는 권한이 앱에 있는지 확인을 해주고, 권한이 없다면 권한을 얻어 카메라 앱을 사용하도록 해줍시다. MainActivity.kt package com.example.myapplication import android.content.Intent import android.content.pm.PackageManager import androidx.appcompat.app.AppCompatActivity import a.. 2021. 2. 24.
[android][kotlin] Json과 RecyclerView Json으로 값을 받아와 RecyclerView와 CardView를 이용해 각 객체들을 나열해보겠습니다. json과 gson에 대한 설명은 이 블로그에 잘 정리가 되어있더군요. 앱에서 인터넷을 사용할 것이기때문에 Menifest에 권한을 포함해주어야합니다. 아래의 코드 두 줄을 Menifest에 추가해줍시다. 직렬화되어 전달된 json을 java객체로 전환시켜주는 gson라이브러리를 사용하기위해 gradle에 아래의 코드를 추가해줍시다. implementation 'com.google.code.gson:gson:2.8.6' 화면부터 꾸며주고 activity_main.xml 정보들을 이쁘게 담아줄 카드뷰를 만들어줍시다. item_person.xml Json으로 받아온걸 직렬화해서 클래스로 가지고있어줍시다... 2021. 2. 17.
[android][xml] TabLayout bottom에 위치시키기 stackoverflow.com/questions/33380668/how-to-set-android-tablayout-in-the-bottom-of-the-screen How to set android TabLayout in the bottom of the screen? My question is how I can set the new android material design TabLayout to be in the bottom of the screen, kind of like Instagram's bottom toolbar. If you have never seen Instagram's UI here is a stackoverflow.com 여기서 알아낸 방법! 다양한 방법이 있겠지만 그 중에서도 가.. 2021. 2. 7.
[algospot] FESTIVAL. 록 페스티벌 (종만북) <C++> algospot.com/judge/problem/read/FESTIVAL algospot.com :: FESTIVAL 록 페스티벌 문제 정보 문제 커다란 공연장을 빌려서 록 페스티벌을 개최하려고 합니다. 이 페스티벌은 여러 날 동안 진행되며, 하루에 한 팀의 밴드가 공연장에서 콘서트를 하게 됩니다. 전체 algospot.com 이전에 사둔 종만북을 심심할 때마다 천천히 읽어보려고 한다. 요즘 사용하고있는 kotlin언어를 사용할 수 없어 아쉬웠다. (나아아는... C++하고 kotlin밖에 모르는데에...ㅠㅠ) 문제 풀이 생각과 구현이 편한 방법을 선택했다. . . . 이런 식으로 계속해서 해나가는 간단한 방법. 정답 코드 #include using namespace std; int main() { in.. 2021. 2. 6.
[android] [xml] 버튼 둥글게 만들기 (corner에 radius 주기) 뷰의 모서리를 둥글게 만들어주려면 커스텀 모양을 만들어주어야합니다! Drawable에 xml파일을 만들어주어 버튼 모양을 만들어줍시다! solid_button.xml 그리고 이렇게 만든 모양을 버튼에 입혀주면 끝! activity_main.xml 2021. 1. 27.
[kotlin] collection (List, Set, Map) kotlinlang.org/docs/reference/collections-overview.html Collections Overview - Kotlin Programming Language kotlinlang.org 우선, list, set, map세 녀석은 기본적으로는 오직 참조만할 수 있는, 즉 수정할 수 없는 immutable의 속성을 가지고 있습니다. 그러나 mutable하게 해줄 수 있습니다. list를 예로 들어보자면 val list = listOf("one", "two", "one") //immutable val list = mutableListOf("one", "two", "one") //mutable 간단하쥬? 자 이제 각각 살펴봅시다~ List List는 배열과 매우 비슷합니다. in.. 2021. 1. 14.
[kotlin] arrays 배열 kotlinlang.org/docs/reference/basic-types.html#arrays Basic Types: Numbers, Strings, Arrays - Kotlin Programming Language kotlinlang.org 배열 생성 방법 var n = IntArrayOf(1,2,3) val n1 = IntArray(5) { 42 } //42로 초기화 var n2 = IntArray(5) { it * 1 } //[0] = 0*1, [1] = 1*1, [2] = 2*1, [3] = 3*1, [4] = 4*1 가장 많이 쓰이는 방법. 그 외에도 val n = arrayOf(1, 2, 3) 배열 참조 방법 println(n.get(0)) println(n[0]) 배열 수정 방법 n.set.. 2021. 1. 14.
[kotlin] Functions 함수 kotlinlang.org/docs/reference/basic-syntax.html#defining-functions Basic Syntax - Kotlin Programming Language kotlinlang.org && kotlinlang.org/docs/reference/functions.html Functions: infix, vararg, tailrec - Kotlin Programming Language kotlinlang.org 기본 형태 //int sum(int a, int b) { // return a+b; //} fun sum(a: Int, b: Int): Int { return a + b } 함수 내용이 적을 때 아래와 같이 한 줄로 축약할 수도 있다. fun sum(a: Int.. 2021. 1. 13.
[android] [kotlin] Retrofit을 사용한 로그인 서비스 보호되어 있는 글 입니다. 2021. 1. 6.
728x90