ANDROID ROOM - USE LIVEDATA TO CONTROL BUTTON STATES

Dmitry Klokov·2020년 12월 26일
0
post-thumbnail

RECORD THE SLEEP QUALITY

        <ImageView
            android:id="@+id/quality_three_image"
				...
            android:onClick="@{() -> viewModel.onSetSleepQuality(3)}"
				...
            app:srcCompat="@drawable/ic_sleep_3" />

CONTROL BUTTON VISIBILITY & ADD SNACKBAR

android:enabled

ColorStateList
https://developer.android.com/guide/topics/resources/color-list-resource
StateListDrawable
https://developer.android.com/guide/topics/resources/drawable-resource#StateList

<!-- android:id="@+id/start_button" -->
android:enabled="@{sleepTrackerViewModel.startButtonVisible}"
<!-- android:id="@+id/stop_button" -->
android:enabled="@{sleepTrackerViewModel.stopButtonVisible}"
<!-- android:id="@+id/clear_button" -->
android:enabled="@{sleepTrackerViewModel.clearButtonVisible}"

Snackbar
https://material.io/components/snackbars/android#using-snackbars

SUMMARY

Learn more

Navigation
https://developer.android.com/topic/libraries/architecture/navigation/
Designing Back and Up navigation
https://developer.android.com/training/design-navigation/ancestral-temporal
Snackbar
https://material.io/develop/android/components/snackbar/

SUMMARY

Triggering navigation

Setting the android:enabled attribute

Other points covered in this codelab

profile
Power Weekend

0개의 댓글