Android Programming The Big Nerd Ranch Guide, 3rd Edition
217 11. Using ViewPager In this chapter, you will create a new activity to host CrimeFragment. This activity’s layout will consi ...
Chapter 11 Using ViewPager 218 Figure 11.2 shows an updated diagram for CriminalIntent. The new activity will be named CrimePag ...
Creating CrimePagerActivity 219 Creating CrimePagerActivity CrimePagerActivity will be a subclass of AppCompatActivity. It will ...
Chapter 11 Using ViewPager 220 In CrimePagerActivity, set the ViewPager’s pager adapter and implement its getCount() and getIte ...
Integrating CrimePagerActivity 221 Integrating CrimePagerActivity Now you can begin the process of decommissioning CrimeActivity ...
Chapter 11 Using ViewPager 222 You also need to add CrimePagerActivity to the manifest so that the OS can start it. While you a ...
FragmentStatePagerAdapter vs FragmentPagerAdapter 223 FragmentStatePagerAdapter vs FragmentPagerAdapter There is another PagerAd ...
Chapter 11 Using ViewPager 224 Figure 11.5 FragmentPagerAdapter’s fragment management Which kind of adapter you should use dep ...
For the More Curious: Laying Out Views in Code 225 When would you need to implement the PagerAdapter interface yourself? When yo ...
Chapter 11 Using ViewPager 226 In fact, you could have defined your ViewPager in code without a layout file at all: @Override p ...
227 12. Dialogs Dialogs demand attention and input from the user. They are useful for presenting a choice or important informati ...
Chapter 12 Dialogs 228 When Lollipop was released, dialogs were given a visual makeover. AlertDialogs on Lollipop automatically ...
Creating a DialogFragment 229 For CriminalIntent, you are going to create a DialogFragment subclass named DatePickerFragment. Wi ...
Chapter 12 Dialogs 230 Create a new class named DatePickerFragment and make its superclass DialogFragment. Be sure to choose th ...
Showing a DialogFragment 231 Showing a DialogFragment Like all fragments, instances of DialogFragment are managed by the Fragmen ...
Chapter 12 Dialogs 232 Run CriminalIntent and press the date button to see the dialog (Figure 12.4). Figure 12.4 An AlertDialo ...
Setting a dialog’s contents 233 In DatePickerFragment.onCreateDialog(Bundle), inflate this view and then set it on the dialog. L ...
Chapter 12 Dialogs 234 Figure 12.7 An AlertDialog with a DatePicker Either version works fine. The newer one sure is pretty, t ...
Passing Data Between Two Fragments 235 Your dialog is onscreen and looks good. In the next section, you will wire it up to prese ...
Chapter 12 Dialogs 236 Passing data to DatePickerFragment To get data into your DatePickerFragment, you are going to stash the ...
«
8
9
10
11
12
13
14
15
16
17
»
Free download pdf