일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- ChromeCustomTab
- circlecrop
- webview
- Android
- requestPermission
- application
- 403 Error
- shotcut
- ExifInterface
- navigation component
- kdoc-generator
- skipcollapsed
- notification setting
- Blinking
- notification
- prettyJson
- itemAnimator
- 이미지 gps
- datastore
- LOG
- App Startup
- ActivityResultContracts
- onResume
- jsontokotlinclass
- BottomSheetDialog
- onReceivedSslError
- room
- notification bar
- Git
- Plugins
- Today
- Total
목록안드로이드/Tip (19)
Debbi Story
안드로이드 LinearLayout 사용시 비율을 주고싶을때 사용하는 속성! layout_weight이 있습니다. 타입은 float형으로 되어있는데요. 저는 DataBinding과 ViewModel을 사용해 값을 변경해주고 싶었지만 오류가 생깁니다!! 아래 처럼 BindingAdapter를 사용하면 됩니다! object MainBindings { @JvmStatic @BindingAdapter("android:layout_weight") fun setLayoutWeight(view: View, weight: Float) { val layoutParams = view.layoutParams as? LinearLayout.LayoutParams layoutParams?.let { it.weight = weig..
ViewPager2는 RecyclerView.Adapter 와 FragmentStateAdpater를 사용할 수 있습니다. 그중에 FragmentStateAdpater를 사용했을때 notifyDataSetChanged()를 해도 갱신이 안될 때 getItemId 와 containsItem 를 override 해주시면 됩니다! 아래는 예시 입니다. class ViewPager2Adapter(fm: FragmentManager, private val fmList: ArrayList) : FragmentStateAdapter(fm) { private val fmIds = fmList.map { it.hashCode().toLong() } override fun getItemCount(): Int { retur..
기존에 ViewPager 어댑터로는 PagerAdapter, FragmentPagerAdapter, FragmentStatePagerAdapter 이렇게 3가지를 사용할 수 있었고, 새로운 ViewPager2에서는 RecyclerView.Adapter 와 FragmentStateAdpater 로 변경되었습니다. FragmentStateAdpater 생성자 인자로 FragmentManager가 필요한데 ViewPager2가 Fragment 안에 있을경우 childFragmentManager 를 넣어주어야 합니다. Activity 안에 있다면 supportFragmentManager 를 사용하면 됩니다.