본문 바로가기
반응형

안드로이드16

[Kotlin] Android SweetAlertDialog 사용하기 SweetAlertDialog 한..5년전에 많이 쓰던건데 아직도 있네요. 버전업은 안되는것 같지만 동작은 잘 됩니다. 이것만한 Dialog Library 가 없네요. 만들어주신분 감사~ Dependency 추가 build.gradle 파일에 dependencies { implementation 'com.github.f0ris.sweetalert:library:1.6.2' } 그리고 우측 상단에 Sync Now 클릭. 사용 Activity 에서 SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("Hello~") .setContentText("Bryan! Good-Night") .setConfirmText("GoodNight") .se.. 2023. 9. 1.
[Kotlin] 안드로이드 Custom Dialog Dialog Layout 생성 res/layout 에서 우클릭 파일이름은 custom_common_dialog.xml 참고: 파일명을 이렇게 만들면 바인딩은 CustomCommonDialogBinding 이 됩니다. 이런 모양이 생깁니다. Dialog Class Dialog 를 상속받은 class 를 생성합니다. CommonDialog.kt import android.app.Dialog import android.content.Context import android.os.Bundle import com.example.solbarapp.databinding.CustomCommonDialogBinding class CommonDialog(context: Context, val title: String, v.. 2023. 9. 1.
[Kotlin] Android ListView ItemClick Listener ListView 가 아래와 같이 있을 때, viewBinding 을 사용했다면 binding.listviewtestListview 로 쓸수있습니다. binding 이 아니면 findViewById 로 listview 를 가져오면됩니다. binding.listviewtestListview.setOnItemClickListener { parent, view, position, id -> // do something.. } 이전 글에서 ListView 를 만들었을 때, 아래와 같이 사용할 수 있습니다. 아래는 LiveData 를 조회했기 때문이고요. binding.listviewtestListview.setOnItemClickListener { parent, view, position, id -> val it.. 2023. 8. 31.
[Kotlin] Android ROOM + LiveData + ListView Android ROOM LiveData ListView ROOM 을 사용해서 LiveData 를 조회하고 ListView 에 Adapter 로 바인딩 해서, 데이터가 수정되면 ListView 에 바로 적용되는 것을 확인해보겠습니다. 실제로 앱을 만들면서 하시려면 이전 글부터 하시면 됩니다. 2023.08.24 - [Android] - [Kotlin] 코틀린 Room Database 사용하기. CRUD Retrofit2 로 데이터 조회해서 Room db에 데이터 넣으려면 아래 글을.. 2023.08.24 - [Android] - [Kotlin] 코틀린 안드로이드 ROOM (database) 사용해보기 Activty 생성 적당한 이름의 Activity 를 생성합니다. 그리고 Binding 사용하도록 코드 수.. 2023. 8. 31.
[Kotlin] 코틀린 Room Database 사용하기. CRUD Android Kotlin ROOM build.gradle 아래 내용 추가 plugins { id 'kotlin-kapt' } dependencies { def room_version = "2.5.2" implementation "androidx.room:room-runtime:${room_version}" implementation "androidx.room:room-ktx:${room_version}" kapt "androidx.room:room-compiler:${room_version}" } sync_now 클릭 Entity (Table) data class Person.kt 데이터 클래스 import androidx.room.ColumnInfo import androidx.room.Entity .. 2023. 8. 24.
[Android] BuildConfig 오류 Cannot resolve symbol 'BuildConfig' 해결 Cannot resolve symbol 'BuildConfig' Activity 에서 앱 최초 생성했을 때나, Build > Clean Project 하면 발생하는데요, 이럴땐, 빌드하면 됩니다.. 오류없이 빌드 되고 나면, BuildConfig 를 못찾는다는 메시지는 안나옵니다. Custom Class 에서 import your.package.name.BuildConfig; 하시면 됩니다. 주의! 다른 라이브러리의 BuildConfig 를 import 하면 안됩니다. 저렇게 되면 rootbeer 라는 버전명을 가져오겠네요 ㄷㄷ 참고 소스오류도 아닌데... 잘못된게 없는데... 뭔가 이상하다.. 싶으면 clean -> build (make project) 한번 해보시면 해결되는 경우가 간혹 있습니다.. ㅋ 2022. 3. 4.
[Android] (androidx) Vertical SeekBar (세로 Seekbar) 이런 Vertical SeekBar 와 ChangeEvent 를 만들어보겠습니다. 이전 버전의 android 에서는 단순히 Seekbar 를 rotate 만 하면 됐나봅니다. 샘플 소스들을 찾아보면 rotate 하라는 말 밖에 없네요. 따라 해봤는데 아래와 같이 나옵니다. Try 1. 이 화면의 layout 은 Background 가 Rotation 기준으로 나옵니다. layout 은 width, height 가 그대로 나오는데요. 그리고 이상한건, Seekbar 의 길이가 아주 짧다는겁니다. 여기서 width 와 height 를 바꿔볼까요? Try 2. 이 layout 은 아래와 같습니다. 이것도 좀 이상합니다. left_toLeftOf = parent 로 했는데 왼쪽으로 안붙네요. width 가 ma.. 2020. 7. 22.
[Android] 코드에서 속도 체크 SystemClock uptimeMillis 코드 속도 체크 SystemClock.uptimeMillis() 속도 체크를 하고 싶은 시작 부분에 Long start = SystemClock.uptimeMillis(); 종료 부분에 Long end = SystemClock.uptimeMillis(); Log.d("#SPEEDTEST", "for using stream : " + (end-start) + "ms"); 테스트 stream 을 이용한 loop 와 그냥 for loop 의 속도를 비교해볼까요? // stream 이용 Long start = SystemClock.uptimeMillis(); filteredList = orgList.stream().filter(f->isTagExists(f.getTag(), tagList)).collect(Co.. 2020. 4. 8.
[Android] androidx 에서 File 공유하기, File Share androidx file share androidx 파일 공유 결과 화면입니다. app > res > xml > file_provider.xml 을 생성합니다. file_provider.xml AndroidManifest.xml app > manifests > AndroidManifest.xml 에 부분을 추가합니다. 사용( Activity 에서 ) File extRoot = getExternalFilesDir(null); String someFile = "/test/some.xls"; File xlsFile = new File(extRoot, someFile); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("appli.. 2020. 3. 3.
[Android] Get only file name from path (파일명만 가져오기) get file name from file path 파일path에서 파일명만 가져오기 변수 타입에따라 골라서 쓰면 되겠죠~ File을 사용하는 방법. File file = new File("/storage/sdcard0/DCIM/Camera/hello_bryan.jpg"); String strFileName = file.getName(); Log.d("TEST", strFileName);// -> hello_bryan.jpg substring 사용 방법. String path = "/storage/sdcard0/DCIM/Camera/hello_bryan.jpg"; String filename=path.substring(path.lastIndexOf("/")+1); Uri 일때 Uri.getLastPath.. 2020. 3. 3.
728x90
반응형