Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)
Creating BeatBox Open the newly renamed fragment_beat_box.xml. Delete the existing contents of the file. Then fill it up like so ...
Chapter 20 Data Binding and MVVM Simple data binding The next job is to inflate fragment_beat_box.xml and hook up its RecyclerV ...
Simple data binding So your FragmentBeatBoxBinding class has two references: getRoot(), which refers to the entire layout, and r ...
Chapter 20 Data Binding and MVVM With your binding created, you can now get at your RecyclerView and configure it. Listing 20.7 ...
Simple data binding Next, create a SoundHolder wired up to list_item_sound.xml. Listing 20.9 Creating SoundHolder (BeatBoxFragm ...
Chapter 20 Data Binding and MVVM Now wire up SoundAdapter in onCreateView(...). Listing 20.11 Wiring up SoundAdapter (BeatBoxF ...
Importing Assets Figure 20.3 Creating the assets folder Click Finish to create your assets folder. Next, right-click on assets ...
Chapter 20 Data Binding and MVVM So where can you find the sounds? You will be using a Creative Commons-licensed sound set we i ...
Getting At Assets Assets are accessed using the AssetManager class. You can get an AssetManager from any Context. Since BeatBox ...
Chapter 20 Data Binding and MVVM To verify that this is working correctly, create an instance of BeatBox in BeatBoxFragment. Li ...
Wiring Up Assets for Use In the constructor, you do a little work to make a presentable name for your sound. First, you split of ...
Chapter 20 Data Binding and MVVM And then pass in BeatBox’s sounds in onCreateView(...). Listing 20.19 Passing in Sounds to ad ...
Binding to Data Binding to Data With data binding, you can declare data objects within your layout file: <layout xmlns:androi ...
Chapter 20 Data Binding and MVVM However, this causes some architectural issues. To see why, look at it from an MVC perspective ...
Creating a ViewModel Creating a ViewModel Let’s create your view model. Create a new class called SoundViewModel and give it two ...
Chapter 20 Data Binding and MVVM Binding to a ViewModel Now to integrate the view model into your layout file. The first step i ...
Binding to a ViewModel Inside your constructor, you construct and attach your view model. Then, in your bind method, you update ...
Chapter 20 Data Binding and MVVM Observable data All may appear to be well, but darkness lies hidden in your code. You can see ...
Observable data Three steps are required with this method: Subclass BaseObservable in your view model. Annotate your view model ...
Chapter 20 Data Binding and MVVM Figure 20.13 All done Accessing Assets You have finished all the work for this chapter. You w ...
«
16
17
18
19
20
21
22
23
24
25
»
Free download pdf