![]() ![]() To communicate data between Fragments and a host Activity or the Activity’s otherįragments, it’s considered best practice to do so through the host Activity-this makes theįragments more reusable, because they do not refer to one another directly. 9 | Deleting a contact from the database.ĭeveloper.android/guide/components/fragments.htmlĪ) Details for a contact b) Deleting the selected contactĩ Technologies Overview 329 9.3 Communicating Data Between a Fragment and a Host Activity Users to go back to prior Fragments via the back button. (LIFO) order-to provide automatic support for Android’s back button ( ). In addition, you’ll useĪndroid’s Fragment back stack-a data structure that stores Fragments in last-in-first-out To do this, you’ll use the FragmentManagerĪnd FragmentTransactions to dynamically display Fragments. Play the Fragment containing the contact list and display the Fragments for viewing,Īdding and editing contacts as they’re needed. Phone-sized device, you’ll display one Fragment at a time. In this app, you’ll use only one Activity to host all of the app’s Fragments. Vice, and a single Activity to host multiple Fragments on a tablet device. ![]() Strated how to use multiple activities to host each of the app’s Fragments on a phone de. Or, for a DialogFragment, called its show method to create it. In earlier apps that used Fragments, you declared each Fragment in an Activity’s layout 9.3 Displaying Fragments with FragmentTransactions This section introduces the features you’ll use to build the Address Book app. 9 | Adding a contact to the database.Ī) Touch the FloatingActionButton to add a new contact b) Fragment for adding the contactģ28 Chapter 9 Address Book App 9 Technologies Overview Tails are displayed next to the contact list (Fig. On a tablet, after adding a contact, the new contact’s de. The contact, you can simply touch the device’s back button to return to the main screen.Īdd more contacts if you wish. The contact in the database and return to the app’s main screen. After adding the contact’s information, touch to store The app requires eachĬontact to have a name, so the save ( ) FloatingActionButton appears only when the TionButton to display the screen for adding a new entry (Fig. The first time you run the app, the contact list will be empty. Open Android Studio and open the Address Book app from the AddressBook folder in theīook’s examples folder, then execute the app in the AVD or on a device. 9 | Address Book running in landscape on a tablet.Ī) In landscape orientation on a phone or tablet, the app bar icons are displayed with their textģ26 Chapter 9 Address Book App 9 Test-Driving the Address Book App Through the app’s complete source code, discussing the app’s new features in more detail. Next, you’ll create the app’s GUI and resource files. Then we’ll overview the technologies we used to build Nously outside the GUI thread and to receive those results in the GUI thread.įinally, you’ll define styles containing common GUI attributes and values, thenįirst, you’ll test-drive the app. You’ll use a LoaderManager and Loaders to perform database access asynchro. To perform database insert, update, delete and query operations. You’ll use a ContentProvider, a ContentResolver and a SQLiteDatabase object You’ll create and open a database with a subclass of SQLiteOpenHelper. You’ll display database data in a RecyclerView. Through the Fragments that have been displayed. You’ll also take advantage of the Fragmentīack stack to enable back-button support, so the user can navigate backward You’ll dynamically add Fragments to and remove Fragments from an Activity’s This app presents several new technologies: ![]() Values, then apply them to multiple GUI components.ĩ.10 Superclass and Implemented Interfaceĩ.12 Superclass and Implemented Interfaceĩ.13 Superclass and Implemented Interface ■ Define styles containing common GUI attributes and ■ Use Cursors to manipulate database query results. ■ Use a LoaderManager and Loaders to perform databaseĪccess asynchronously outside the GUI thread. ■ Use a ContentResolver to invoke methods of aĬontentProvider to perform tasks with a database. ![]() Object to interact with data in a SQLite database. ■ Use a ContentProvider and a SQLiteDatabase ■ Create and open databases with SQLiteOpenHelper. ■ Use a RecyclerView to display data from a database. ■ Use FragmentTransactions and the back stack toĭynamically attach Fragments to and detach Fragments 9 Address Book App FragmentTransactions and the Fragment Back Stack, SQLite, SQLiteDatabase, SQLiteOpenHelper, ContentProvider, ContentResolver, Loader, LoaderManager, Cursor and GUI Styles Objectives ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |