본문 바로가기

전체 글310

Kotlin] 안드로이드 채팅방 날짜 표시 How do I display the calendar date on the top of chat messages? I am working on a chat application but I am struggling to figure out how to display the calendar date on the top of chat messages; for example, something like this: Another image with timestamps: ... stackoverflow.com 각 채팅 메세지에 대한 Adapter에 해당 코드를 넣어준다. override fun onBindViewHolder(holder: ViewHolder, position: Int) { holder.bind(ch.. 2021. 5. 1.
Android] 다른 액티비티에서 프라그먼트 교체 / 뷰페이저 A프라그먼트에서 a액티비티로 화면 전환 후, a액티비티 화면에서 back 버튼으로 갔을 때 이전과 다른 B프라그먼트가 나오도록 하는 코드. #뷰페이저 두 프라그먼트는 같은 액티비티 안에 있어야 합니다. A 액티비티내 프라그먼트에서 B 액티비티로 이동 val intent = Intent(activity, B::class.java) activity?.startActivityForResult(intent, 12345) B 액티비티에서 setResult 설정 setResult(Activity.RESULT_OK) 프라그먼트를 가진 액티비티의 뷰페이저 currentItem 변경. #onActivityResult if (requestCode == 12345) { if (RESULT_OK == resultCode) {.. 2021. 4. 29.
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.
오늘 와우 금융주 은행주 증권주 카뱅 인터넷은행 2021. 4. 20.
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.