In this tutorial, we are going to build up a simple guessing game. First, a short introduction to the game. The essence of the game is to figure out a hidden, randomly generated number. This number is between 1 and 10. We have endless possibilities to try.
From Android development side, we are going to use in this tutorial 2 Jetpack libraries, which are the Data Binding and the Navigaion Component. Then, we will use the MVVM design pattern, together with LiveData and ViewModel.
In our app, we will have only one Activity. This activity will hold a fragment, where we will define the view of the game and from this fragment we can open a bottom sheet dialog also.
This tutorial assumes that you have former knowledge about Android development and you are familiar with the basics of the Android Jetpack componenets.
If you need some knowledge update about the basics of Data Binding, then check out the Data Binding – Basics tutorial.
In this tutorial, we are going to use Navigation Component as well. If you need to refresh the usage of this library either, then here is a tutorial also: Navigation Component
The demo app
- Enable Data Binding
- Transform the layouts
- Navigation Component
- Open the Bottom Sheet Dialog
- Change the username
- Real time update using layout variables
- Play the game
- Define the LiveDatas
- Creation of the business logic
- Result of the guess
- Binding Adapters
- Show the result
- Visualize the result
I hope the description was understandable and clear. But, if you have still questions, then leave me comments below! 😉
Have a nice a day! 🙂