Question

Q) MyBooks is an android application has a homepage "Activity_MyBooks.xml" that shows a simple li...

Q) MyBooks is an android application has a homepage "Activity_MyBooks.xml" that shows a simple list. This list displays only the book title for each book in the user’s book database. The database has a table name “Books” which has the following fields (Book_id, BookTitle, Author, Year). This App connected to the Database by BookstDataSource class and BooksDBHelper class.

Explain the following questions on your own words and no need to write a code.

  1. Explain how to create the Layout for the list in MyBooks App?

  1. Explain the steps of creating the Data Source method for the list in MyBooks App?

Answers

  1. Creatint the Layout for the list

Two components are required for any list implementation in Android: a ListView widget and an adapter. The ListView widget is an object that can display a vertical list of items that can be scrolled through. An Adapter is dynamically associated with the ListView. The adapter provides access to the underlying data source for the list.

  • The visible component of a list is implemented with a ListView widget in an XML layout file. In many ways, a ListView is a standard widget. However, if given the special ID of @id/android:list and a special subclass of Activity , many of the tasks of list implementation are easier because the developer can take advantage of many built-in features of the SDK. To take advantage of these features, the Activity associated with the layout containing the ListView must be a subclass of ListActivity rather than Activity.
  • Lists require the use of an adapter. The adapter provides access to the data items and is responsible for creating a View for each item.

  1. Creating the Data Source method

The first step to implementing the simple list is to have data. For this, we need to add a method to the “BookstDataSource” class that will retrieve each item.

The primary function is that the query can return more than one record to the cursor, so we have to implement a loop to retrieve all the records.

  1. The return value for this method is an ArrayList . An ArrayList is an object that acts like an array in that the data it holds can be accessed through an index. In contrast to an array, the ArrayList is not a fixed size. It can grow as data is added to it. An ArrayList is parameterized. So if we use <String> portion of the code. This says that the values in the ArrayList are all of the String data type. So, this can be used to display book title field
  2. The SQL query is set up to return the fields for all records in the Books table.
  3. A loop is set up to go through all the records in the cursor. The loop is initialized by moving to the first record in the cursor. Next, the while loop is set up to test if the end of the cursor’s record set has been reached. Within the loop, the book title is added to the ArrayList, and the cursor is advanced to the next record.
  4. The ArrayList is set to a new empty ArrayList in case the routine crashes partially through its filling. This way, the calling Activity can test for an empty list to determine if the retrieve was successful.

Note: I need only to paraphrase the Answer . So its does not match the answers with other students

0 0
Add a comment Improve this question Transcribed image text
Answer #1

nuen daba my Bod i an andsted appliaatton hasa hoepage Recommandations s peadingchaliorge current Readi favourite ng → frien

Add a comment
Know the answer?
Add Answer to:
Q) MyBooks is an android application has a homepage "Activity_MyBooks.xml" that shows a simple li...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will...

    AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will improve our personal lending library tool by (1) adding the ability to delete items from the library, (2) creating a graphical user interface that shows the contents of the library and allows the user to add, delete, check out, or check in an item. (3) using a file to store the library contents so that they persist between program executions, and (4) removing the...

  • This is in C. For this assignment we will write a simple database server. We will...

    This is in C. For this assignment we will write a simple database server. We will be creating a simple database of student records, so let’s describe these first. The format of a student record is as follows: typedef struct student {     char lname[ 10 ], initial, fname[ 10 ];     unsigned long SID;     float GPA; } SREC; Part One – the Server We will create a database server. The job of the server is to accept a...

  • Quiz 5 Chapter 21 Multiple Choice Identify the choice that best completes the statement or newer...

    Quiz 5 Chapter 21 Multiple Choice Identify the choice that best completes the statement or newer the question 1. In this chapter, media is defined as a type of communication. b. a type of ink. c. data storage devices. d. A and C 2. What statement is not correct? a. A personal computer is a single user electronic data processing device. b. A personal computer and peripheral devices are hardware. c. Output devices allow data to be entered into the...

  • Creating a simple graph in C++; need solution ASAP. EDIT: Pls comment letting me know what...

    Creating a simple graph in C++; need solution ASAP. EDIT: Pls comment letting me know what other information you need rather than just "..." Thank you. Here is the assignment: In this final practice problem, you’ll: read a set of data representing a directed, unweighted graph build an in-memory graph structure using the data display the graph using depth-first traversal display the graph using breadth-first traversal Input data - The data consists of records like this: 16 3 15 4...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • How does this article relate to the factors of productions in economics? From Music to Maps,...

    How does this article relate to the factors of productions in economics? From Music to Maps, How Apple’s iPhone Changed Business Ten years ago, hailing a cab meant waiving one's arm at passing traffic, consumers routinely purchased cameras, and a phone was something people made calls on. The iPhone, released a decade ago this month, changed all of that and more, sparking a business transformation as sweeping as the one triggered by the personal computer in the 1980s. Apple Inc.'s...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT