본문 바로가기

IT/Android101

Android] Coroutine 재시작, 다시 호출하기 fun startCoroutine() = CoroutineScope(Dispatchers.Main).launch { //runBlocking도 가능하지만 지양 val job = async(start = CoroutineStart.LAZY) { Jobb() } Log.d("startCoroutine", "TAG") job.await() } ... // 코루틴 suspend fun Jobb() = CoroutineScope(Dispatchers.Main).launch { ... #async #lazy #suspend fun 2021. 4. 26.
Kotlin] 안드로이드 키보드 검색 xml editText.setOnEditorActionListener { v, actionId, event -> when (actionId) { EditorInfo.IME_ACTION_SEARCH -> {} else -> { } } false } 2021. 3. 23.
Kotlin] 안드로이드 버튼 눌린 상태로 유지 버튼 한번 클릭했을 때 눌린 상태로 유지되도록 합니다. 눌렸을 때랑 안 눌렸을 때를 구분하도록 selector를 만듭니다 이때 state_pressed가 아니라 state_selected를 사용한다 그리고 버튼 클릭시 selected 여부를 바꿔줍니다. button?.setOnClickListener { button?.isSelected = button?.isSelected != true } 안드로이드 - 안드로이드 이미지뷰 버튼 누른상태 유지 - 안드로이드 Q&A 안녕하세요 이미지뷰 버튼 누른 상태를 유지하려고 하는데 selector를 만들어서 focused, selected 등 설정은 하였습니다. 그러나 누를때 잠시 깜빡 하고 사라집니다.. 이렇게 말고 누르면 누른상태를 www.masterqna.com 2021. 3. 23.
Kotlin] 안드로이드 이미지 공유하기 // Android share image 이미지를 공유합니다, 버튼을 누르면 공유할 수 있는 앱이 나타납니다 button_share.setOnClickListener { val intent = Intent(Intent.ACTION_SEND) // 이미지 uri val uri: Uri = Uri.parse(imgUri.toString()) intent.type = ("image/*") intent.putExtra(Intent.EXTRA_STREAM, uri) startActivity(Intent.createChooser(intent, "Share img")) } 인텐트 이미지 타입을 image/png로 하면 공유가 안되는 앱도 있습니다. intent.type = ("image/*") developers.facebook.com/docs/instag.. 2021. 3. 21.